Add request_id middleware test, doc comments, and validation constants - #944
Merged
Maki-Zeninn merged 1 commit intoJul 28, 2026
Conversation
Addresses three code-review findings against the current main branch: - metrics/src/server.rs: request_id_middleware attaches a UUID to every response as the x-request-id header and this behavior is documented as a user-facing contract in the module docs, but no test exercised it. Add test_request_id_middleware_sets_response_header, which layers the middleware onto a minimal router and asserts the header is present and non-empty on the response, so a regression (renamed header, dropped layer) fails CI instead of shipping silently. - contracts/router-core/src/lib.rs: set_route_dependency, get_route_dependencies, and resolve_with_dependencies had only a one-line summary, unlike every other public function in the file. Add matching # Arguments / # Returns / # Errors sections, listing the specific RouterError variants each function can return (including CircularDependency and RecursionLimitExceeded, which were previously undocumented), so integrators can discover error conditions without reading the implementation. - metrics/src/validation.rs: the contract ID length (56) and route name length (64) were hardcoded as magic numbers in both the checks and the error messages, and repeated again in tests. Introduce STELLAR_CONTRACT_ID_LEN and MAX_ROUTE_NAME_LEN constants, use them via format! in the error messages, and reference them from the test module instead of repeating literals, so the limits can be changed in one place.
|
@Onomebello Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
this pr closes #908
this pr closes #909
this pr closes #910
this pr closes #911
Addresses three code-review findings against the current main branch:
metrics/src/server.rs: request_id_middleware attaches a UUID to every response as the x-request-id header and this behavior is documented as a user-facing contract in the module docs, but no test exercised it. Add test_request_id_middleware_sets_response_header, which layers the middleware onto a minimal router and asserts the header is present and non-empty on the response, so a regression (renamed header, dropped layer) fails CI instead of shipping silently.
contracts/router-core/src/lib.rs: set_route_dependency, get_route_dependencies, and resolve_with_dependencies had only a one-line summary, unlike every other public function in the file. Add matching # Arguments / # Returns / # Errors sections, listing the specific RouterError variants each function can return (including CircularDependency and RecursionLimitExceeded, which were previously undocumented), so integrators can discover error conditions without reading the implementation.
metrics/src/validation.rs: the contract ID length (56) and route name length (64) were hardcoded as magic numbers in both the checks and the error messages, and repeated again in tests. Introduce STELLAR_CONTRACT_ID_LEN and MAX_ROUTE_NAME_LEN constants, use them via format! in the error messages, and reference them from the test module instead of repeating literals, so the limits can be changed in one place.