Description
In ros_mcp/resources/ros_metadata.py, the get_all_ros_metadata() function has a vulnerability in the topics handling code that mirrors the bug fixed in PR #236 for services.
Problem
The topics code at lines 78-81 uses:
metadata["topics"] = [
{"name": topic, "type": topic_type}
for topic, topic_type in zip(topics, types)
]
If types is empty or has a different length than topics, this will silently drop topics - the same issue that was fixed for services.
Expected Behavior
Topics should be returned with "type": "unknown" when type information is unavailable, rather than being dropped entirely.
Suggested Fix
Apply the same fallback pattern used for services:
if types and len(types) == len(topics):
metadata["topics"] = [
{"name": topic, "type": topic_type}
for topic, topic_type in zip(topics, types)
]
else:
metadata["topics"] = [
{"name": topic, "type": "unknown"} for topic in topics
]
Related
Description
In
ros_mcp/resources/ros_metadata.py, theget_all_ros_metadata()function has a vulnerability in the topics handling code that mirrors the bug fixed in PR #236 for services.Problem
The topics code at lines 78-81 uses:
If
typesis empty or has a different length thantopics, this will silently drop topics - the same issue that was fixed for services.Expected Behavior
Topics should be returned with
"type": "unknown"when type information is unavailable, rather than being dropped entirely.Suggested Fix
Apply the same fallback pattern used for services:
Related