#3904·axum

InnerPath fails on invalid UTF-8 captured by an outer router

Author: januththedevCreated Sep 26, 2026Updated Sep 26, 2026

Description

InnerPath rejects a nested route when an outer router capture contains invalid UTF-8, even though the capture is not part of the inner router's result.

Reproduction

rust
use axum::Router;
use axum::extract::InnerPath;
use axum::routing::get;

let app = Router::new().nest(
    "/org/{org}",
    Router::new().route("/team/{team_id}", get(|InnerPath(p): InnerPath<Vec<(String, String)>>| async move { p })),
);

// GET /org/%FF/team/1337

The outer {org} capture is stored as InvalidUtf8InPathParam before StripPrefix advances the inner offset. InnerPath then returns a 400 for org, even though its documented contract is to return only the captures from the innermost matched route (team_id).

Expected

The invalid outer capture is ignored and the handler receives {team_id: "1337"}.

Actual

The request fails with FailedToDeserializePathParams(InvalidUtf8InPathParam { key: "org" }).

The InnerPath extractor was merged in PR #3856 on 2026-09-25 and is not in the latest release. I found no existing issue or PR for this case.