Repository navigation
fix(subtitles): report why an AI subtitle job failed - #2271
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Findings
|
| Layer / File(s) | Summary |
|---|---|
Normalize and classify AI failures internal/ai/llm/*, internal/ai/translate/translate.go, internal/api/handlers/admin_settings_checks.go |
LLM response errors use typed failure categories, including unusable responses. Translation format-retry failures have a sentinel, and admin transcription checks use the shared classifier. |
Map and record subtitle-job failure reasons internal/subtitles/ai/*, internal/ai/jobrunner/runner.go |
Subtitle jobs map known errors to viewer-facing reasons for persisted failures and live notifications. The service uses shared markers for cancellation, interruption, missing or unsupported sources, and no speech. |
Expose safe reasons to API and player internal/apiv2/subtitle_ai_reads.go, internal/api/handlers/subtitle_ai.go, internal/api/handlers/subtitle_ai_reads_test.go, web/src/player/components/VideoPlayer.tsx, web/src/player/components/VideoPlayer.test.tsx, docs/subtitles-api.md, contracts/api/v2/fixtures/subtitle_ai_job_opaque_id.json |
API reads use the public failure-message projection. The player displays the reason as the toast description. The documentation and fixture describe the exposed messages. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant Provider
participant LLMClient
participant SubtitleService
participant JobStorage
participant API
participant Player
Provider->>LLMClient: Return response or error
LLMClient->>SubtitleService: Return classified error
SubtitleService->>JobStorage: Persist public failure reason
API->>JobStorage: Read failed job
API-->>Player: Return viewer-facing reason
Player->>Player: Show reason as toast description
Suggested labels: api-v2, impact: usability, evidence-required
Suggested reviewers: quick104
Merge Risk: 
Low · previous review a1a43
-
Streamed rate limits can fail subtitle jobs instead of retrying. A cancellation race can also leave the live reason out of sync with the job.
Security architecture risk: 
Low · up to a1a43
-
The change replaces potentially sensitive diagnostics with fixed viewer-facing reasons. No new access or privilege expansion was identified. Older running versions can still expose diagnostics, so full protection depends on completing the upgrade.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- observed — The inspected bridge list path retains its media-file access check. Live translation notifications are sent to one session after the existing session/file match check, not broadcast to all viewers. The changed message handling does not broaden those delivery paths.
Trust Boundaries and Controls
- observed — The reviewed head interrupts the provider-diagnostic-to-viewer flow at both independent live failure callers and at stored-job API projections. Raw diagnostics remain available to server logging rather than being used as viewer text.
Resilience and Maintainability Implications
- observed — Failure persistence remains restricted to pending or running rows, and final failure handling still declines to overwrite inactive jobs or uncertain publication outcomes. The message-contract change does not remove these terminal-state safeguards.
-
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The pull request description directly explains the changes to classify AI subtitle failures, persist safe viewer-facing reasons, sanitize API responses, update live events, and display reasons in the web player.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7252086a0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summaryReviewed head: a1fd4db. The review started at 81a0da8, and I pushed one fix commit on top. Addressed in a1fd4db
The two earlier Codex threads, about legacy rows on bridge reads and telling a text 413 from an audio 413, were fixed in 81a0da8. I checked both against the code, and the 413 split still holds through the new marker. For the maintainers to settle
Verification
Validated featuresNo passed case is affected. The only recorded passes on the 1.0 board are person and cast browsing (#1138, #1143), which share no code with this change. The PR's User manual and clientsSilo-Server/siloserver.org#159 tracks the manual change, and I added a comment there about the two new reasons. Silo-Server/siloserver.org#241 is the open docs PR. Apple and Android show Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green) Fit: it closes the AC4 gap in the 1.0 AI subtitle criteria. The safe text is chosen at the server boundary that every client already reads, and it adds no new API surface. Readiness: the approach is sound and every finding is fixed. The remaining condition is that a maintainer should watch one failed job, such as a canceled live translation, on a build of a1fd4db, because the fix commit was checked by tests, not on a running server. |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
1 similar comment
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The Evidence section names web desktop/mobile captures and an API excerpt, but not the native screens that render the changed failure reason:
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
All six C4 entries in the PR's Suggested line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Updated the line to Macroscope's suggestion:
All six C4 cells in the Results tables read |
A failed AI subtitle job now records a viewer-facing reason that names the cause: the provider is unreachable, timed out, rejected the key, is rate limiting, needs billing, does not know the model, refused oversized audio, or returned unusable output; or the audio has no speech, the file has no audio, or the source track is not text or is gone. v2 job reads, bridge job reads and the live failure event all carry it, and the raw error with any provider response stays in the server log. Before, v2 reads said only "Subtitle processing failed." and the live event sent the raw provider response to the player. llm.Classify groups provider errors by status so the admin connection check and subtitle jobs share one classification.
…ze limit Bridge job reads now return the same viewer-facing reason as v2, so rows written before reasons were classified no longer expose raw provider text. A provider 413 on a text request names Subtitle lines per request instead of Audio per request.
…ancels A live chunk cancelled mid-request was reported as an unreachable or rate-limited provider, and the cancel event sent the stored token instead of the reason job reads return. Status and message now come from one helper on both notify paths, and events carry the public reason. Only errors from the translator's chat call and the transcription request are classified as provider failures, so an S3 upload or ffmpeg deadline no longer sends the admin to AI Services. Plan-ineligible ChatGPT accounts, cue-less text tracks and unrecognized ChatGPT response failures get their own reasons. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Responses API text path landed on main after this branch was written, so its failures fell through to the generic server reason. A server_error now reads as an unavailable provider, rate_limit_exceeded as rate limited, any other error code as a rejected request, and incomplete, refused or empty output as an unusable response. Retry behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3a913d8 to
a1a4388
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
I rebased this branch onto main (d81ad5d) and force-pushed it, so the branch was rewritten. The four original commits are unchanged apart from two conflict resolutions:
Main also gained a Responses API text path (#3285) after this PR was written. Its failures returned plain errors, so a job that failed there showed the generic server reason. a1a4388 classifies them like the ChatGPT stream: Checked on the rebased head: Posted by Claude Code (claude-opus-5-5) on behalf of @Quick104. |
| case errors.Is(err, errSourceMissing): | ||
| return failureSourceMissing |
There was a problem hiding this comment.
Missing errSourceChanged handling in internal/subtitles/ai/failure.go reports an unexpected server error and advises retrying later instead of reopening the subtitle menu when Service.run passes it to finishWithError after a rescan changes a queued translation's source track. Map errSourceChanged to failureSourceMissing alongside errSourceMissing.
case errors.Is(err, errSourceMissing), errors.Is(err, errSourceChanged):
return failureSourceMissingPrompt for LLM
File internal/subtitles/ai/failure.go:
Line 96 to 97:
Missing errSourceChanged handling in internal/subtitles/ai/failure.go reports an unexpected server error and advises retrying later instead of reopening the subtitle menu when Service.run passes it to finishWithError after a rescan changes a queued translation's source track. Map errSourceChanged to failureSourceMissing alongside errSourceMissing.
Suggested Code:
case errors.Is(err, errSourceMissing), errors.Is(err, errSourceChanged):
return failureSourceMissing
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Confirmed. errSourceChanged came in with #2272 on main after this branch was written, so it fell through to the generic reason. Fixed in db5975e: it now maps to the "track is no longer available" reason, and a new row in TestFailureReasonNamesTheCauseWithoutProviderDetails fails without the fix and passes with it.
Posted by Claude Code (claude-opus-5-5) on behalf of @Quick104.
There was a problem hiding this comment.
Thanks for confirming. The reported fix in db5975e35 addresses the suggestion: errSourceChanged now maps to the “track is no longer available” reason, and the regression test covers the previous fallthrough. No further changes needed for this finding.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1a4388d88
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| failureKeyRejected = "The AI provider rejected the server's credentials. Ask a server administrator to check AI Services." | ||
| failurePlanIneligible = "The ChatGPT account connected to this server can't share its plan usage. Ask a server administrator to check AI Services." | ||
| failureModelNotFound = "The AI provider doesn't recognize the configured model. Ask a server administrator to check AI Services." | ||
| failureAudioTooLarge = "The AI provider rejected the audio as too large. Ask a server administrator to lower Audio per request in AI Services." |
There was a problem hiding this comment.
Target the live chunk limit in oversized live-audio failures
For a live transcription job that receives HTTP 413, lowering Audio per request cannot address the failure: runTranscribe supplies LiveASRChunkSeconds as a per-job override (service.go:474–485), and WhisperTranscriber.Transcribe uses that instead of the subtitle_ai.asr_chunk_seconds setting edited by that control (AISettings.tsx:1004–1005). The next attempt therefore uploads the same-sized chunks despite following this advice. Preserve the live/background request distinction when selecting the reason, or give live jobs guidance targeting subtitle_ai.live_asr_chunk_seconds rather than the batch-only setting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed. A live job passes LiveASRChunkSeconds as the per-job chunk length, so lowering Audio per request (subtitle_ai.asr_chunk_seconds) can't help, and the admin UI doesn't expose the live setting. Fixed in 0b9828e: WhisperTranscriber.Transcribe marks provider errors from a per-job chunk length, and a 413 on those reads "The AI provider rejected live audio as too large. Ask a server administrator to check AI Services." Background jobs keep the Audio per request advice. A new row in TestFailureReasonNamesTheCauseWithoutProviderDetails covers the mapping.
Posted by Claude Code (claude-opus-5-5) on behalf of @Quick104.
errSourceChanged landed on main (Silo-Server#2272) after this branch was written, so a translation whose source track changed during a rescan showed the generic server reason. It now gets the same "track is no longer available" reason as a missing source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
09bb9bb6-d2fa-4726-9825-b60f5c73f434
Files selected for processing: 16-
docs/subtitles-api.mdinternal/ai/llm/api_responses.gointernal/ai/llm/client.gointernal/ai/llm/failure_test.gointernal/ai/llm/responses.gointernal/ai/llm/responses_test.gointernal/ai/llm/transcribe.gointernal/api/handlers/admin_settings_checks.gointernal/subtitles/ai/failure.gointernal/subtitles/ai/failure_test.gointernal/subtitles/ai/service.gointernal/subtitles/ai/service_test.gointernal/subtitles/ai/transcriber.gointernal/subtitles/ai/translator.goweb/src/player/components/VideoPlayer.test.tsxweb/src/player/components/VideoPlayer.tsx
Files skipped from review as they are similar to previous changes: 1-
- web/src/player/components/VideoPlayer.tsx
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.
-
A live transcription uploads audio in subtitle_ai.live_asr_chunk_seconds pieces, so lowering Audio per request (subtitle_ai.asr_chunk_seconds) cannot fix a 413 there. The transcriber marks provider errors from per-job chunk lengths, and those get a reason that points the administrator at AI Services without naming the batch setting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
A response.failed event with rate_limit_exceeded fell through to the permanent fallback, so the job stopped at once and read as a rejected request. It is now a retryable 429, matching the Responses API path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 952f30a602
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func TestSubtitleAIBridgeJobRedactsLegacyFailure(t *testing.T) { | ||
| const raw = `translate cues 1-35: chat API returned 500: {"error": "boom"}` | ||
| legacy := &ai.Job{ID: 3, Status: ai.JobStatusFailed, ErrorMessage: raw} | ||
| got := publicSubtitleAIJob(legacy) |
There was a problem hiding this comment.
Remove the bridge-only redaction test
This new test covers the v1-only projection’s redaction, field copying, and nil handling without exercising authorization. The root AGENTS.md explicitly excludes “frozen /api/v1 behavior beyond its own authorization checks” from new tests. Keep the redaction implementation, but remove this bridge-only test; the shared sanitization behavior is already covered by TestPublicFailureMessageHidesLegacyDiagnostics and the v2 read tests.
AGENTS.md reference: AGENTS.md:L203-L204
Useful? React with 👍 / 👎.
| case llm.FailureNotFound: | ||
| return failureModelNotFound |
There was a problem hiding this comment.
Avoid attributing every provider 404 to an unknown model
When a configured provider lacks the transcription endpoint, its HTTP 404 now produces “The AI provider doesn't recognize the configured model,” even if the model is valid. This is an existing supported failure scenario: llm.decorateTranscribeError explicitly recognizes missing transcription routes and adds guidance to choose a Whisper-compatible endpoint, but this mapping discards that distinction. Use an endpoint-or-model reason, as the admin connection check already does, unless the provider response specifically identifies an unknown model; otherwise users receive misleading troubleshooting guidance in both job reads and the live toast.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed. A provider without a transcription route also answers 404. Fixed in 6edc3a7: the reason now reads "The AI provider doesn't offer the configured endpoint or model. Ask a server administrator to check AI Services.", which matches the admin connection check's endpoint-or-model wording. The raw error, including the Whisper-endpoint hint from decorateTranscribeError, stays in the server log.
Posted by Claude Code (claude-opus-5-5) on behalf of @Quick104.
A provider without a transcription route also answers 404, so the old "doesn't recognize the configured model" reason could point an administrator at a valid model. The reason now names the endpoint or model, like the admin connection check. Also drop the bridge-only redaction test: AGENTS.md keeps frozen /api/v1 tests to authorization, and PublicFailureMessage's own test covers the redaction. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: #1163
Validation tasks: changes #1164 C4; changes #1166 C4; changes Silo-Server/silo-apple#317 C4; changes Silo-Server/silo-apple#318 C4; changes Silo-Server/silo-android#327 C4; changes Silo-Server/silo-android#328 C4
When an AI subtitle job fails, the viewer does not learn why. v2 job reads, which every native player shows, report only "Subtitle processing failed." for anything but provider billing. The live failure event that the web and Apple players show during playback sends the raw provider error instead, for example
translate cues 1-35: chat API returned 500: {"error": …}. The first gives no reason; the second leaks provider responses to viewers.This change records one viewer-facing reason per failed job and sends it on every channel.
Approach
llm.Classifygroups provider errors by what someone can do about them: billing or payment, credentials rejected, unknown model, audio too large, rate limited, provider unavailable, other rejections, timeout, unreachable, unusable response. A 200 reply that carries an upstream error is now a retryable 502, so it reads as "unavailable". On the ChatGPT plan path, plan-ineligible accounts, temporary outages and incomplete streams classify the same way; their admin-facing text is unchanged. The Responses API text path (used for the Ultrafast service tier) classifies the same way: a server error reads as unavailable, a rate limit as rate limited, another error code as a rejected request, and incomplete, refused or empty output as an unusable response. The admin connection check uses the same classification with its existing messages.The subtitle job maps that kind, plus its own causes (no speech, no audio track, source is not a text subtitle, track no longer available), to a fixed message such as "The AI provider is unavailable right now. Try again later." That message is persisted as the job's error, sent on the live failure event, and returned by v2 and bridge job reads. The raw error, including any provider response, stays in the server log. Only errors from provider requests (the translator's chat call and the transcription request) are classified, so storage, database and ffmpeg failures get the generic server reason. A cancellation reports "Subtitle processing was canceled." on both the job and the live event. An ineligible ChatGPT plan account and an empty text track have their own reasons. Rows written before this change still get the generic or billing message on v2.
The web player shows the reason as the toast description under "Subtitle processing failed". Bridge job reads now return the safe reason instead of the raw text;
docs/subtitles-api.mdsays so.Validation
internal/ai/...,internal/subtitles/...,internal/apiv2andinternal/api/handlerssuites; contract fixture regenerated.make lint-changed, web lint, format, build, budget and tests, and everyverify-*target pass.make test-gofails only in packages this change does not touch:internal/apiv2TestAdminResourceCapabilitiesAndScopeandinternal/playbackhardware-probe tests fail the same way onmainon this Mac, and aninternal/transcodenodetiming test failed intermittently under load. CI's Linux run is the reference for those.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2271/
Surface and build: web desktop and mobile, API excerpt; before = main c32feb1, after = this branch, same file and injected failure.
Risks
Bridge (
/api/v1) job reads change from raw error text to the safe reason. No client parses that text. Raw diagnostics move from the job row to the server log only.Checklist
AI Disclosure
Note
Report viewer-facing failure reasons for AI subtitle jobs
llm.Classifymaps provider errors to categories (quota, rate limit, timeout, unusable response, etc.), andinternal/subtitles/ai/failure.gomaps those categories to fixed viewer-facing messages persisted with the job.Service.finishWithErrorNotifynow persists and streams the safe reason while logging the raw error; live translation failure events use the sanitized message too.ai.PublicFailureMessageso v1/v2 job reads and the handler list return viewer-facing reasons instead of raw stored diagnostics, with fallbacks for legacy messages.ErrNoSpeech,errSourceMissing,errSourceEmpty,ErrInvalidModelResponse) let the mapping distinguish no-speech, missing-source, and model-format failures.PublicFailureMessagein failure.go.Macroscope summarized 6edc3a7.