Skip to content

Add request_id middleware test, doc comments, and validation constants - #944

Merged
Maki-Zeninn merged 1 commit into
Maki-Zeninn:mainfrom
Onomebello:chore/address-review-findings-request-id-docs-magic-numbers
Jul 28, 2026
Merged

Add request_id middleware test, doc comments, and validation constants#944
Maki-Zeninn merged 1 commit into
Maki-Zeninn:mainfrom
Onomebello:chore/address-review-findings-request-id-docs-magic-numbers

Conversation

@Onomebello

Copy link
Copy Markdown
Contributor

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.

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.
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Maki-Zeninn
Maki-Zeninn merged commit 9490b33 into Maki-Zeninn:main Jul 28, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment