Skip to content

fix(server): use axum 0.7 path syntax for :id route params (recording/model delete 404s) - #1510

Open
fallen-pc wants to merge 1 commit into
ruvnet:mainfrom
fallen-pc:fix/axum-07-route-param-syntax
Open

fix(server): use axum 0.7 path syntax for :id route params (recording/model delete 404s)#1510
fallen-pc wants to merge 1 commit into
ruvnet:mainfrom
fallen-pc:fix/axum-07-route-param-syntax

Conversation

@fallen-pc

Copy link
Copy Markdown

Problem

DELETE /api/v1/recording/{id} and DELETE /api/v1/models/{id} return 404 for every id. In the dashboard this shows up as recording deletion in the Training tab silently failing.

The routes are declared with {id}:

.route("/api/v1/models/{id}",    delete(delete_model))
.route("/api/v1/recording/{id}", delete(delete_recording))

{param} is the axum 0.8 / matchit 0.8 capture syntax. The workspace pins axum = "0.7" (0.7.9 in Cargo.lock), where captures are :param and {id} is matched as a literal path segment. So no real id ever matches, the request falls through to the 404 fallback, and the handlers are never reached.

Corroborating detail: neither handler is capable of returning 404 - both return Json<serde_json::Value>, i.e. HTTP 200 with an error body:

Json(serde_json::json!({ "error": "recording not found", "success": false }))

so a bare 404 can only mean the route did not match.

Fix

{id} -> :id in five route declarations:

  • main.rs - /api/v1/models/{id}, /api/v1/recording/{id} (both live)
  • model_manager.rs - /api/v1/models/{id}
  • recording.rs - /api/v1/recording/download/{id}, /api/v1/recording/{id}

The latter three are in routers not currently merged into the app, corrected for consistency so they don't reintroduce the bug if they're mounted later.

The format!("/api/v1/sites/{site_id}/...") strings in vendor_mist_netgear.rs are deliberately untouched - those are Rust format interpolation building outbound URLs, not axum routes.

Verification

Built and run locally, --source esp32:

Request Before After
DELETE /api/v1/recording/does-not-exist-test 404 (empty) 200 {"error":"recording not found","success":false}
GET /api/v1/models/<id> 404 405 (path matches, method not registered on the live router)

cargo build -p wifi-densepose-sensing-server clean.

Note

If the project intends to move to axum 0.8, the inverse change would be needed across the whole crate - this PR aligns the routes with the version currently pinned, which is the smaller and safer of the two.

DELETE /api/v1/recording/{id} and DELETE /api/v1/models/{id} returned 404
for every id. The routes were declared with `{id}`, which is the axum 0.8 /
matchit 0.8 capture syntax, but the workspace pins axum 0.7 (0.7.9
resolved), where `{id}` is matched as a literal path segment. No real id
ever matched, so requests fell through to the 404 fallback and never
reached their handlers - visible in the dashboard as recording deletion
failing.

Neither handler can return 404 (both return Json, i.e. HTTP 200), which
confirms the request was never routed.

Changed to `:id` in main.rs (2 live routes) plus model_manager.rs and
recording.rs (3 routes in routers not currently merged, corrected for
consistency).

Verified against a running server:
  DELETE /api/v1/recording/does-not-exist-test
    before: 404 (empty)
    after:  200 {"error":"recording not found","success":false}
  GET /api/v1/models/<id>
    before: 404
    after:  405 (path matches, method not registered)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant