Skip to content

16/feat/get/areas/area id/components#20

Merged
bburda merged 2 commits into
mainfrom
16/feat/GET/areas/area_id/components
Nov 23, 2025
Merged

16/feat/get/areas/area id/components#20
bburda merged 2 commits into
mainfrom
16/feat/GET/areas/area_id/components

Conversation

@mfaferek93

@mfaferek93 mfaferek93 commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator

Pull Request

Description

What changed and why.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Related issues

Fixes # (if applicable)
Related to # (if applicable)

How has this been tested?

Describe the tests you ran to verify your changes.

Checklist

  • My code follows the project's coding style
  • I ran colcon build and the build succeeds without warnings
  • I ran colcon test and all tests pass locally
  • I added/updated tests where applicable
  • I updated documentation where applicable
  • My commit messages are clear and descriptive

Additional notes for reviewers

@mfaferek93 mfaferek93 self-assigned this Nov 23, 2025
@mfaferek93

Copy link
Copy Markdown
Collaborator Author

@copilot please review last commit

Copilot AI commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

@mfaferek93 I've opened a new pull request, #21, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements two new REST API endpoints for component discovery and filtering: /components (lists all components across all areas) and /areas/{area_id}/components (lists components within a specific area). These endpoints enhance the gateway's discovery capabilities by exposing component-level information in addition to the existing area-level data.

Key Changes:

  • Added two new REST endpoint handlers (handle_list_components and handle_area_components) following existing patterns
  • Implemented comprehensive integration tests with proper error case coverage (404 for non-existent areas)
  • Updated documentation with detailed API reference including examples, response structures, and use cases

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ros2_medkit_gateway/src/rest_server.cpp Implements two new endpoint handlers with consistent error handling and JSON serialization
src/ros2_medkit_gateway/include/ros2_medkit_gateway/rest_server.hpp Adds function declarations for the two new endpoint handlers
src/ros2_medkit_gateway/test/test_integration.test.py Adds three comprehensive tests covering component listing, area-filtered components, and 404 error handling; renumbers existing test from test_21_ to test_04_ for sequential ordering
src/ros2_medkit_gateway/README.md Adds extensive API documentation with curl examples, response formats, field descriptions, and use cases for both new endpoints
postman/collections/ros2-medkit-gateway.postman_collection.json Adds two new Postman requests for testing the component endpoints
postman/README.md Updates quick start guide with examples for testing the new endpoints
docs/README.md Updates architecture documentation to reflect the new endpoints

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ros2_medkit_gateway/src/rest_server.cpp Outdated
Comment thread src/ros2_medkit_gateway/test/test_integration.test.py
Add endpoint to list components within a specific area with error handling.

Changes:
- Add REST handler for GET /areas/{area_id}/components with path parameter
- Implement area validation and 404 error response for nonexistent areas
- Filter components by area from entity cache
- Add test_05_area_components_success integration test
- Add test_06_area_components_nonexistent_error integration test
- Update README with API reference, success/error examples, and use cases
- Update Postman collection with new endpoint and testing instructions
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ros2_medkit_gateway/src/rest_server.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ros2_medkit_gateway/src/rest_server.cpp

Copilot AI commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

@mfaferek93 I've opened a new pull request, #22, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bburda bburda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bburda bburda merged commit 754bea6 into main Nov 23, 2025
19 checks passed
@mfaferek93 mfaferek93 deleted the 16/feat/GET/areas/area_id/components branch November 26, 2025 19:56
mfaferek93 added a commit that referenced this pull request Apr 12, 2026
…, backoff

Write error types (#23, #24):
- Change write_value return from bool to tl::expected<void, WriteErrorInfo>
  with specific error codes: NotConnected, TypeMismatch, AccessDenied,
  NodeNotFound, TransportError
- Add data_type_hint parameter to skip the readValue type-probe round-trip
  when the caller knows the expected type from NodeMap; halves mutex hold
  time on writes
- Callers (vendor route handlers + DataProvider::write_data +
  OperationProvider::execute_operation) map WriteError codes to
  appropriate HTTP status (400 for type mismatch, 403 for access denied,
  502 for transport errors) instead of generic 502 for all failures

YAML validation (#19):
- Validate required fields (node_id, entity_id, data_name) per entry;
  skip with RCLCPP_WARN if missing
- Validate data_type is one of bool/int/float/string; default to float
  with warning if unknown
- Detect duplicate node_id entries; first wins, subsequent skipped with
  warning
- Cap node count at 10000 to prevent DDS resource exhaustion from
  oversized configs
- Replace all std::cerr output with RCLCPP_WARN/RCLCPP_ERROR for
  structured logging

Poll interval clamp (#20):
- Clamp poll_interval_ms to [100, 60000] in configure() so sub-100ms
  values no longer cause a CPU spin even without the condition_variable
  fix from the previous commit

Exponential backoff on reconnect (#28):
- Double the reconnect wait on each failed attempt, capped at 60s
- Reset to configured interval on successful reconnect
- Prevents network and log saturation when PLC is down for extended
  periods
mfaferek93 added a commit that referenced this pull request Apr 12, 2026
…rams

Extract shared parse_coerce_validate() helper (#3 review comment):
- Value parsing (bool/int/string/float dispatch), range validation, and
  type coercion were duplicated in handle_plc_operations, write_data,
  and execute_operation. The three copies had already diverged (write_data
  was missing data_type_hint). Now all three call parse_coerce_validate()
  from an anonymous namespace, keeping them in sync.

Document missing parameters (#20 review comment):
- Add subscription_interval_ms to the Gateway Parameters table
- Document the optional ros2_topic field in node map entries
- Update poll_interval_ms description to note [100, 60000] ms clamping
mfaferek93 added a commit that referenced this pull request Apr 12, 2026
…, backoff

Write error types (#23, #24):
- Change write_value return from bool to tl::expected<void, WriteErrorInfo>
  with specific error codes: NotConnected, TypeMismatch, AccessDenied,
  NodeNotFound, TransportError
- Add data_type_hint parameter to skip the readValue type-probe round-trip
  when the caller knows the expected type from NodeMap; halves mutex hold
  time on writes
- Callers (vendor route handlers + DataProvider::write_data +
  OperationProvider::execute_operation) map WriteError codes to
  appropriate HTTP status (400 for type mismatch, 403 for access denied,
  502 for transport errors) instead of generic 502 for all failures

YAML validation (#19):
- Validate required fields (node_id, entity_id, data_name) per entry;
  skip with RCLCPP_WARN if missing
- Validate data_type is one of bool/int/float/string; default to float
  with warning if unknown
- Detect duplicate node_id entries; first wins, subsequent skipped with
  warning
- Cap node count at 10000 to prevent DDS resource exhaustion from
  oversized configs
- Replace all std::cerr output with RCLCPP_WARN/RCLCPP_ERROR for
  structured logging

Poll interval clamp (#20):
- Clamp poll_interval_ms to [100, 60000] in configure() so sub-100ms
  values no longer cause a CPU spin even without the condition_variable
  fix from the previous commit

Exponential backoff on reconnect (#28):
- Double the reconnect wait on each failed attempt, capped at 60s
- Reset to configured interval on successful reconnect
- Prevents network and log saturation when PLC is down for extended
  periods
mfaferek93 added a commit that referenced this pull request Apr 12, 2026
…rams

Extract shared parse_coerce_validate() helper (#3 review comment):
- Value parsing (bool/int/string/float dispatch), range validation, and
  type coercion were duplicated in handle_plc_operations, write_data,
  and execute_operation. The three copies had already diverged (write_data
  was missing data_type_hint). Now all three call parse_coerce_validate()
  from an anonymous namespace, keeping them in sync.

Document missing parameters (#20 review comment):
- Add subscription_interval_ms to the Gateway Parameters table
- Document the optional ros2_topic field in node map entries
- Update poll_interval_ms description to note [100, 60000] ms clamping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement GET /areas/{area_id}/components endpoint to list components within a specific area

4 participants