insertion failed due to conflict with previously registered route: /*__private__axum_fallback'
alcroito opened this issue · 1 comments
alcroito commented
Hi.
Upgrading to latest axum in my project has broken schema generation.
I get the following panic:
hread 'web::routes::tests::generate_open_api_schema' panicked at 'Invalid route "/*__private__axum_fallback": insertion failed due to conflict with previously registered route: /*__private__axum_fallback', /Users/myuser/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aide-0.11.0/src/axum/mod.rs:453:35
stack backtrace:
0: rust_begin_unwind
at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/panicking.rs:64:14
2: axum::routing::Router<S,B>::nest
at /Users/myuser/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.18/src/routing/mod.rs:164:13
3: aide::axum::ApiRouter<S,B>::nest
at /Users/myuser/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aide-0.11.0/src/axum/mod.rs:453:23
4: do_ddns::web::routes::get_pure_router_and_open_api
at ./src/web/routes.rs:70:24
5: do_ddns::web::routes::tests::generate_open_api_schema
at ./src/web/routes.rs:126:24
6: do_ddns::web::routes::tests::generate_open_api_schema::{{closure}}
at ./src/web/routes.rs:125:35
7: core::ops::function::FnOnce::call_once
at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/ops/function.rs:250:5
8: core::ops::function::FnOnce::call_once
at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/ops/function.rs:250:5
Code in question: https://github.com/alcroito/digitalocean-dyndns/blob/master/crates/dyndns/src/web/routes.rs#L70
New axum version: 0.6.18
Previously working one: 0.6.12.
I haven't had time to make a small repro yet, but posting for visibility.
alcroito commented
Ok, made a small repro. Looks like it's not an aide issue, but either an axum issue or how i'm using fallback for nesting under '/'.
use aide::axum::ApiRouter;
use aide::openapi::OpenApi;
use axum::Router;
#[derive(Clone)]
struct SomeState;
async fn serve_static_files() { todo!() }
fn static_router() -> Router<SomeState> {
Router::new().fallback(serve_static_files)
}
fn make_router() {
let mut api = OpenApi::default();
let static_router: ApiRouter<SomeState> = static_router().into();
let _final_router = ApiRouter::new()
.nest("/", static_router)
.finish_api(&mut api);
}
fn main() {
make_router();
}