Repository navigation
fix(api): surface ListDownloadedSubtitles errors instead of masking as 404 - #256
Conversation
…s 404
The web subtitle handler wrapped the downloaded-subtitle lookup in
`if err == nil { ... }`, so a real DB/backing-store failure from
ListDownloadedSubtitles was silently swallowed and control fell through
to a generic 404 ("Subtitle track not found") with no server-side signal.
This made genuine internal failures look like an intermittent client-side
"subtitles won't render" bug and left nothing in the logs to diagnose.
On error, log at ERROR (with file_id/track/error, matching the sibling
font-extraction path) and return 500 — mirroring the neighbouring error
handling in the same branch (S3 GetObject -> 502, ConvertToVTT -> 500).
The genuine not-found fall-through is preserved for the case where the
listing succeeds but the requested index is out of range.
Closes #248
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe stream subtitle handler now treats ChangesSubtitle listing error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant StreamHandler
participant SubtitleRepo
Client->>StreamHandler: GET /subtitles/{track}.vtt
StreamHandler->>SubtitleRepo: ListDownloadedSubtitles(file_id)
alt listing fails
SubtitleRepo-->>StreamHandler: error
StreamHandler->>StreamHandler: log error with file_id, track
StreamHandler-->>Client: 500 internal_error
else listing succeeds
SubtitleRepo-->>StreamHandler: subtitle list
StreamHandler-->>Client: serve ASS/VTT track
end
Related issues: Suggested labels: bug, backend Suggested reviewers: (none identified from provided context) 🐰 A subtitle went missing, or so it seemed, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…s 404 (Silo-Server#256) The web subtitle handler wrapped the downloaded-subtitle lookup in `if err == nil { ... }`, so a real DB/backing-store failure from ListDownloadedSubtitles was silently swallowed and control fell through to a generic 404 ("Subtitle track not found") with no server-side signal. This made genuine internal failures look like an intermittent client-side "subtitles won't render" bug and left nothing in the logs to diagnose. On error, log at ERROR (with file_id/track/error, matching the sibling font-extraction path) and return 500 — mirroring the neighbouring error handling in the same branch (S3 GetObject -> 502, ConvertToVTT -> 500). The genuine not-found fall-through is preserved for the case where the listing succeeds but the requested index is out of range. Closes Silo-Server#248 Co-authored-by: Claude Opus 4.8 <[email protected]>
Problem
The web subtitle handler (
HandleSubtitleininternal/api/handlers/stream.go) wrapped the downloaded-subtitle lookup inif err == nil { ... }. WhenListDownloadedSubtitlesfailed (DB/backing-store error), the error was silently swallowed: control fell through to a genericwriteError(404, "Subtitle track not found")with no logging and no server-side signal. A real internal failure was reported to the client as "subtitle not found", which is exactly why issue #248 looked like an intermittent, hard-to-diagnose client-side "subtitles won't render" bug.Reproduced with a focused handler test: on the unpatched code, a repo returning an error yields
404 {"error":"not_found"}; with the fix it yields500 {"error":"internal_error"}plus anERRORlog line (list downloaded subtitles failed file_id=42 track=0 error="db unavailable").Approach
On
err != nil, log atERRORwithfile_id/track/error(matching the sibling font-extraction path in the same file) and return500 internal_error— mirroring the neighbouring error handling in the very same branch (S3.GetObject→ 502,ConvertToVTT→ 500). The successful-serve path and the genuine not-found fall-through (listing succeeds but the requested index is out of range) are left byte-for-byte unchanged; the large diff is just one level of de-indentation after replacing theif err == nilwrapper with an early return.Scope is deliberately limited to error handling + logging, per the issue — this does not touch the downstream content/deployment-specific render behavior.
Verification
All run inside the worktree with
GOWORK=offand a stubbedweb/distper the repo's worktree conventions:GOWORK=off go build ./internal/... ./cmd/...→ cleanTestHandleSubtitle_ListDownloadedSubtitlesErrorReturns500: red on origin/main (asserts 404 masking), green with the fix (500 +internal_error)GOWORK=off go test ./internal/api/handlers/→ok(full package suite, no regressions)golangci-lint(v2): no new findings on the touched lines (the only findings referencing the touched file are pre-existingstubEpisodeLookupdead code already onorigin/main)make verify-local-paths→ exit 0Test infra reuses the existing
handlerMockSubtitleRepo/handlerMockS3Client(added alistErrhook) rather than duplicating a mock.Adversarial review
Codex adversarial review (
--base main): approve — no material findings. It independently confirmed the failure path now logs + returns 500 while the success path and the nil-list/out-of-range 404 fall-through remain unchanged.Risks & follow-up
Low risk: additive, server-side observability only. The status code for a genuine internal failure changes from a (wrong) 404 to a (correct) 500 on the existing endpoint — clients already treat 5xx as a transient/server error, so no client contract field/type changes and no
silo-android/silo-applefollow-up is required. No migration.Closes #248
AI-use disclosure
Implemented by Claude Code (issue-to-pr skill) with human oversight.
🤖 Generated with Claude Code
Summary by CodeRabbit