From 8a6eebabfd20c126e12cf53d61930a3b844230c6 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Thu, 26 Mar 2026 22:48:19 +0400 Subject: [PATCH] Fix axum route params: use :param syntax (not {param}) for axum 0.7 Axum 0.7 uses :param for path parameters. {param} is axum 0.8+ syntax. Routes were silently not matching, causing 404 on all key lookups. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../crates/warzone-server/src/routes/keys.rs | 30 ++++++++++++++----- .../warzone-server/src/routes/messages.rs | 4 +-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/warzone/crates/warzone-server/src/routes/keys.rs b/warzone/crates/warzone-server/src/routes/keys.rs index 44a404f..5ca1c0f 100644 --- a/warzone/crates/warzone-server/src/routes/keys.rs +++ b/warzone/crates/warzone-server/src/routes/keys.rs @@ -11,7 +11,7 @@ pub fn routes() -> Router { Router::new() .route("/keys/register", post(register_keys)) .route("/keys/list", get(list_keys)) - .route("/keys/{fingerprint}", get(get_bundle)) + .route("/keys/:fingerprint", get(get_bundle)) } /// Debug endpoint: list all registered fingerprints. @@ -63,15 +63,29 @@ async fn get_bundle( Path(fingerprint): Path, ) -> Result, axum::http::StatusCode> { let key = normalize_fp(&fingerprint); - tracing::info!("Looking up bundle for {}", key); + tracing::info!("get_bundle: raw path='{}', normalized='{}'", fingerprint, key); + + // Debug: list what's in the DB + let all_keys: Vec = state.db.keys.iter() + .filter_map(|r| r.ok().and_then(|(k, _)| String::from_utf8(k.to_vec()).ok())) + .collect(); + tracing::info!("get_bundle: DB contains {} keys: {:?}", all_keys.len(), all_keys); + match state.db.keys.get(key.as_bytes()) { - Ok(Some(data)) => Ok(Json(serde_json::json!({ - "fingerprint": fingerprint, - "bundle": base64::Engine::encode(&base64::engine::general_purpose::STANDARD, &data), - }))), - _ => { - tracing::warn!("Bundle not found for {}", key); + Ok(Some(data)) => { + tracing::info!("get_bundle: FOUND {} bytes for {}", data.len(), key); + Ok(Json(serde_json::json!({ + "fingerprint": fingerprint, + "bundle": base64::Engine::encode(&base64::engine::general_purpose::STANDARD, &data), + }))) + } + Ok(None) => { + tracing::warn!("get_bundle: NOT FOUND for key '{}'", key); Err(axum::http::StatusCode::NOT_FOUND) } + Err(e) => { + tracing::error!("get_bundle: DB error: {}", e); + Err(axum::http::StatusCode::INTERNAL_SERVER_ERROR) + } } } diff --git a/warzone/crates/warzone-server/src/routes/messages.rs b/warzone/crates/warzone-server/src/routes/messages.rs index 89b6b65..f026d71 100644 --- a/warzone/crates/warzone-server/src/routes/messages.rs +++ b/warzone/crates/warzone-server/src/routes/messages.rs @@ -11,8 +11,8 @@ use crate::state::AppState; pub fn routes() -> Router { Router::new() .route("/messages/send", post(send_message)) - .route("/messages/poll/{fingerprint}", get(poll_messages)) - .route("/messages/{id}/ack", delete(ack_message)) + .route("/messages/poll/:fingerprint", get(poll_messages)) + .route("/messages/:id/ack", delete(ack_message)) } #[derive(Deserialize)]