Skip to content

fix: trim trailing slashes before routing - #254

Draft
TwoDCube wants to merge 1 commit into
test/integrationfrom
fix/trailing-slash
Draft

TwoDCube wants to merge 1 commit into
test/integrationfrom
fix/trailing-slash

Conversation

@TwoDCube

Copy link
Copy Markdown
Member

Fixes a bug recorded by the tests in #247. Stacked on #247 (base test/integration), so this is a draft until #246 and #247 merge.

Bug

The middleware stack applied trim_trailing_slash() with Router::layer. Per axum 0.8.9's documentation ("Rewriting request URI in middleware"), middleware added with Router::layer runs after routing, so it cannot change which route matches. POST /graphql/ and GET /liveness/ returned 404.

Fix

  • app() no longer trims inside the router. It wraps the whole router in NormalizePathLayer::trim_trailing_slash() and returns IntoMakeService<NormalizePath<Router>>.
  • The signature change is the only API change. Both callers (run and test-utils) pass the value straight to axum::serve, so neither needed changes.

Tests

  • trailing_slash_is_ignored is no longer ignored. It also checks GET /liveness/, /readiness/ and /graphql/.
  • No snapshots change.
  • cargo clippy --workspace --all-targets -D warnings is clean. CI=true cargo test --workspace passes against MySQL 8.4 and Redis 6.2.

🤖 Generated with Claude Code

trim_trailing_slash was added with Router::layer, and middleware added that
way runs after routing, so a request to /graphql/ found no route and got a
404. Wrap the whole router in NormalizePathLayer instead, as axum's
documentation on rewriting the request URI in middleware describes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@verseghy-prow

verseghy-prow Bot commented Sep 14, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TwoDCube

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@verseghy-prow verseghy-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant