Skip to content

Conversation

LHolten
Copy link
Contributor

@LHolten LHolten commented Sep 24, 2024

Fixes #2930
Motivation and solution as proposed in that issue.

Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Thanks!

@jplatte jplatte enabled auto-merge (squash) September 24, 2024 17:11
@jplatte
Copy link
Member

jplatte commented Sep 24, 2024

Side note: It appears that the email you have configured git to use as part of your author identity is not one that you told GitHub about, which is why the commits here are not linked to your profile.

The squashed commit that will be merged will be associated to your profile though, since GitHub uses the PR author's primary email for this (a gmail address in this case). If that's a problem for you, let me know (even if already merged).

@jplatte jplatte merged commit 4179d11 into tokio-rs:main Sep 24, 2024
18 checks passed
@LHolten
Copy link
Contributor Author

LHolten commented Sep 24, 2024

Thanks for the note! I don't mind that it used my primary email, but I will try to add the second email to be associated with my account.

xmo-odoo added a commit to xmo-odoo/dummy_central that referenced this pull request Feb 21, 2025
…are about

That was a pain to debug as axum only traces it in... well debug[^1],
otherwise you just get a 500 with no information.

I'd always assumed that

    Router::new()
        .nest("/{foo}/{bar}",
            Router:new()
                .route(...)
                .route(...)
                .layer(map_request(map_fn)))

would receive just the `Path` from the parent router, but apparently
it "inherits" the path from the route being matched, meaning the
`Path((_, _))` of `normalize_repo_name` would receive *4* components
if the request was to `/objects`, but would ignore the last two.

tokio-rs/axum#2931 changed this behaviour such that `Path<Tuple>` now
only allows exact extractions, and this applies to `map_request`'s
handler.

In this case we specifically know that we only care about the `name`
of the repository, so we can leverage a bespoke `struct` and that
serde ignores extra / unknown fields by default, without needing a
more expensive deserialization target (e.g. a full hashmap).

[^1]: and not precisely, axum does mention the `Path` size mismatch
    but doesn't say where it happens.
@LHolten LHolten deleted the strict-tuple-path-extract branch August 18, 2025 12:38
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.

Check that number of path parameters matches tuple path extractor exactly
2 participants