fix(gateway): use entity cache for detail endpoints instead of DiscoveryManager#326
Merged
mfaferek93 merged 2 commits intomainfrom Mar 30, 2026
Merged
fix(gateway): use entity cache for detail endpoints instead of DiscoveryManager#326mfaferek93 merged 2 commits intomainfrom
mfaferek93 merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Switches discovery detail/relationship handlers to use ThreadSafeEntityCache for entity lookups, fixing inconsistencies where entities listed from the cache could 404 on detail endpoints due to DiscoveryManager re-discovery.
Changes:
- Replaced
DiscoveryManager::get_area/get_component/get_app/get_functionusage withThreadSafeEntityCachelookups in multiple detail handlers. - Updated several relationship handlers to resolve related entity IDs via cache indexes and then fetch entity details from the cache.
- Reduced reliance on per-request ROS graph re-discovery for affected endpoints.
src/ros2_medkit_gateway/src/http/handlers/discovery_handlers.cpp
Outdated
Show resolved
Hide resolved
c627a08 to
f55921a
Compare
…eryManager
Detail handlers (GET /areas/{id}, /components/{id}, /apps/{id},
/functions/{id}) used DiscoveryManager::get_*() which re-discovers
from ROS 2 graph on each call. This missed topic-source and synthetic
components that are only present in the cache (populated during
periodic discovery refresh).
Switch entity detail handlers to use ThreadSafeEntityCache which
already has the complete entity set including topic-source components.
List endpoints already used the cache, so this makes behavior consistent.
Relationship endpoints (contains, hosts, depends-on, subcomponents,
function-hosts) keep using DiscoveryManager for hierarchy resolution
and to return fresh discovery state (e.g., is_online status).
Fixes #319
f55921a to
f79ccbb
Compare
bburda
requested changes
Mar 30, 2026
Collaborator
bburda
left a comment
There was a problem hiding this comment.
Two issues:
handle_app_depends_oninner loop still usesdiscovery->get_app(dep_id)(see inline)- No regression integration test -
test_discovery_heuristic.test.pyonly tests list endpoints in runtime_only mode. A "list then detail" test for synthetic components would guard against this exact bug scenario.
src/ros2_medkit_gateway/src/http/handlers/discovery_handlers.cpp
Outdated
Show resolved
Hide resolved
handle_app_depends_on and handle_function_hosts used discovery->get_app() for dependency/host lookups - same bug class this PR fixes. Synthetic/topic-source apps would incorrectly show as missing. Switch to cache.get_app() consistently. Update test expectations: is_online now reflects cache state (enriched during runtime linking) rather than discovery default.
bburda
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Detail handlers used DiscoveryManager::get_*() which re-discovers from ROS 2 graph on each call. This missed topic-source and synthetic components that are only present in the entity cache. List endpoints already used the cache, causing inconsistency: GET /components lists topic-source components but GET /components/{id} returns 404.
Switch all entity detail and relationship handlers to use ThreadSafeEntityCache.
Test plan
Fixes #319