fix(server): audio routes answer 400 for server-side failures where siblings return 500
- Dominant language
- Rust
- Stars
- 467
- Forks
- 54
- Avg merge
- 4h 25m
- Merged PRs (30d)
- 310
Description
## Summary
Six failure paths in the audio routes return HTTP 400 for server-side failures (worker panics, response-builder failures, inference errors) because they build `ErrorResponse::new(..., "server_error")` without setting `.status`, inheriting the constructor's `BAD_REQUEST` default. The sibling embeddings and rerank routes handle the identical case and explicitly return 500.
## Background
`ErrorResponse::new` defaults the status to `BAD_REQUEST`. A server-side failure carrying `"type": "server_error"` but an HTTP 400 status is contradictory and misleads clients and proxies into treating a server fault as a client error. The embeddings and rerank routes already set `INTERNAL_SERVER_ERROR` for the same class of failure, so the audio routes are the outlier.
## Proposed Solution
Set `INTERNAL_SERVER_ERROR` at each of the six sites (or use the shared constructor from #1690 if that lands first), and add one assertion to the existing test so the `Inference` arm is pinned.
## Implementation Notes
- Affected sites (confirmed `server_error` with no `.status`): `src/server/routes/audio.rs:100`, `:278`, `:306`, `:373`, `:493`, `:548-551`.
- Default: `src/server/types/response.rs:489` (`ErrorResponse::new`) returns `StatusCode::BAD_REQUEST`.
- Convention to match: `src/server/routes/embeddings.rs:74-81` and `src/server/routes/rerank.rs:69-76` set `INTERNAL_SERVER_ERROR` for the same case (rerank confirmed in source).
- The existing test `model_error_maps_kinds_and_inference` (`audio.rs:597-616`) asserts status for `KindNotLoaded` / `QueueFull` / `Timeout` but skips `Inference`, so nothing pins the current 400.
## Acceptance Criteria
- [ ] All six sites answer 500 with `"type": "server_error"`.
- [ ] The `Inference` arm is pinned by the existing test.
---
## Original Suggestion
### Title: fix(server): audio routes answer 400 for server-side failures where siblings return 500
Six failure paths in the audio routes answer HTTP 400 for server-side failures — worker panics, response-builder failures, inference errors — because they build `ErrorResponse::new(..., "server_error")` without setting `.status`, inheriting the constructor's `BAD_REQUEST` default. The sibling embeddings and rerank routes hit the identical case and explicitly bump to 500.
## Evidence
- Affected sites: `src/server/routes/audio.rs:100`, `:278`, `:306`, `:373`, `:493`, `:548-551`
- Default: `src/server/types/response.rs:496` — `ErrorResponse::new` defaults to `StatusCode::BAD_REQUEST`
- Convention: `src/server/routes/embeddings.rs:74-81` and `src/server/routes/rerank.rs:69-76` set `INTERNAL_SERVER_ERROR` for the same case
- The existing test `model_error_maps_kinds_and_inference` (`audio.rs:597-616`) asserts status for `KindNotLoaded`/`QueueFull`/`Timeout` but skips `Inference`, so nothing pins the current 400
## Suggested fix
One status assignment per site (or use the shared 500 constructor proposed in the companion `ErrorResponse::internal_server_error` issue if that lands first), plus one added assertion line in the existing test.
## Acceptance criteria
- [ ] All six sites answer 500 with `"type": "server_error"`
- [ ] The `Inference` arm is pinned by the existing test
Contributor guide
Research direction
Start in src/server/routes/audio.rs at the six listed sites and compare their error handling with src/server/routes/embeddings.rs and src/server/routes/rerank.rs. Run the existing model_error_maps_kinds_and_inference test in audio.rs, then verify that all six server_error paths return HTTP 500 and that the Inference arm asserts this status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100