The public API handlers (crates/api/src/public.rs) map db errors to 500 via .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) / Err(_) => INTERNAL_SERVER_ERROR, discarding the underlying sqlx::Error. A 500 with no trace makes production debugging hard. The api crate currently has no tracing dependency (the server crate does).
What to do
Add tracing to the api crate.
Log the discarded error on every 500 path, e.g.:
.map_err(|err|{tracing::error!(?err,"db error listing public objects");StatusCode::INTERNAL_SERVER_ERROR})
Apply consistently across list_objects and get_object (and future handlers).
Surfaced by the Plan 7 Task 3 code-quality review.
## Context
The public API handlers (`crates/api/src/public.rs`) map db errors to `500` via `.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)` / `Err(_) => INTERNAL_SERVER_ERROR`, **discarding the underlying `sqlx::Error`**. A 500 with no trace makes production debugging hard. The `api` crate currently has no `tracing` dependency (the `server` crate does).
## What to do
- Add `tracing` to the `api` crate.
- Log the discarded error on every 500 path, e.g.:
```rust
.map_err(|err| { tracing::error!(?err, "db error listing public objects"); StatusCode::INTERNAL_SERVER_ERROR })
```
- Apply consistently across `list_objects` and `get_object` (and future handlers).
## References
- `crates/api/src/public.rs` — `list_objects`, `get_object`
- Surfaced by the Plan 7 Task 3 code-quality review.
Scope note from the admin-CRUD work (merged main @ c4e0c4c): the new admin handlers follow the same pattern as the public surface — .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) with the underlying error discarded and no tracing. This affects crates/api/src/admin_objects.rs, admin_vocab.rs, and admin_authorities.rs. When wiring tracing, cover the whole api crate's 500 paths, not just the public endpoints.
Scope note from the admin-CRUD work (merged `main` @ `c4e0c4c`): the new admin handlers follow the same pattern as the public surface — `.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)` with the underlying error discarded and no tracing. This affects `crates/api/src/admin_objects.rs`, `admin_vocab.rs`, and `admin_authorities.rs`. When wiring tracing, cover the whole `api` crate's 500 paths, not just the public endpoints.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Context
The public API handlers (
crates/api/src/public.rs) map db errors to500via.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)/Err(_) => INTERNAL_SERVER_ERROR, discarding the underlyingsqlx::Error. A 500 with no trace makes production debugging hard. Theapicrate currently has notracingdependency (theservercrate does).What to do
tracingto theapicrate.list_objectsandget_object(and future handlers).References
crates/api/src/public.rs—list_objects,get_objectScope note from the admin-CRUD work (merged
main@c4e0c4c): the new admin handlers follow the same pattern as the public surface —.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)with the underlying error discarded and no tracing. This affectscrates/api/src/admin_objects.rs,admin_vocab.rs, andadmin_authorities.rs. When wiring tracing, cover the wholeapicrate's 500 paths, not just the public endpoints.