Repository navigation
fix(audio): unbuildable audio surfaces as terminal 'unavailable' instead of pending-forever - #7877
Conversation
…ot pending-forever The handler consumed the task but nothing recorded the verdict, so /urls kept reporting pending while named-task tombstones silently blocked re-enqueues — clients polled to exhaustion (live prod report: a March conversation whose chunks no longer exist in storage).
Greptile SummaryThis PR introduces a terminal
Confidence Score: 5/5Safe to merge — all three terminal-drop paths now write the unavailable marker, clients stop polling immediately, and the 30-day lifecycle rule handles eventual cleanup. The change is narrow and well-contained: a single new marker blob and matching read on each /urls poll, with coordinated changes across the merge handler, Flutter, and web that all point at the same new state. All three previously open gaps (chunks_missing, failed_final, empty_audio) are now plugged, the pre-loop fast-path in AudioPlayer correctly short-circuits before entering the 90 s polling loop, and the type definitions on both web and Flutter match the new backend contract. No existing happy-path logic is modified. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Client (Flutter / Web)
participant URLs as /urls endpoint
participant GCS as GCS Storage
participant Task as Merge Cloud Task
Note over Client,Task: Happy path (unchanged)
Client->>URLs: GET /urls
URLs->>GCS: get_playback_artifact_signed_url
GCS-->>URLs: signed URL
URLs-->>Client: status cached
Note over Client,Task: Unavailable path (NEW)
Task->>GCS: _build_playback_artifact FileNotFoundError
Task->>GCS: mark_playback_unavailable write .unavailable blob
Task-->>Task: return 200 dropped chunks_missing
Client->>URLs: GET /urls next poll or initial load
URLs->>GCS: get_playback_artifact_signed_url null
URLs->>GCS: is_playback_unavailable true
URLs-->>Client: status unavailable
Client-->>Client: Show error immediately stop polling
Note over Client,Task: Pending path (unchanged)
Client->>URLs: GET /urls
URLs->>GCS: get_playback_artifact_signed_url null
URLs->>GCS: is_playback_unavailable false
URLs-->>Client: status pending poll_after_ms N
URLs->>Task: enqueue_conversation_audio_merge
Client->>Client: sleep pollAfterMs retry
Reviews (2): Last reviewed commit: "fix(web): thread audio status so unavail..." | Re-trigger Greptile |
…comes Greptile P1: the chunks_missing branch wrote the unavailable marker, but the failed_final (max-retry exhaustion) and empty_audio branches consumed the task without one — the named-task tombstone then blocks re-enqueue, leaving the file pending forever. Same trap, different failure mode.
Greptile nit: AudioPlayer guarded firstFile.status but mapAudioUrls dropped the field, making the guard dead code (one wasted poll round-trip before the loop caught it). Carry status through the type and mapper.
|
@greptile-apps re-review |
Bug (found in prod ~1h after flipping #7872)
A March conversation got stuck at "preparing audio" until timeout on share/play. Trace:
audio_merge: chunks missing ... dropping) — that conversation's audio predates current chunk retention and is unrecoverable by any pipeline (it failed under the old inline merge too, with a different timeout flavor)./urlskept reporting the file aspending, while Cloud Tasks named-task tombstones silently blocked every re-enqueue (already enqueued, skipping duplicateon each poll).Fix
A terminal
unavailablestate:chunks_missing, writes a tiny marker blob (playback/{uid}/{conv}/{file}.unavailable, content = reason) before consuming the task./urls: artifact missing + marker present →status: "unavailable"— no enqueue, no poll hint.unavailableis excluded fromhasPending, so the poll loop exits immediately and the existing error path (snackbar +audioPlaybackFailed) fires instead of 90s of spinning. Share fails fast the same way.The marker lives under
playback/, so the existing 30-day lifecycle rule auto-clears it — even genuinely transient chunk-listing failures get a retry within a month, with zero extra machinery.Tests
4 new structural tests in
test_audio_merge_tasks.py(marker written on chunks-missing,/urlsunavailable branch without enqueue, storage helpers, app terminal handling) — 15/15 passing; tsc + dart analyze clean.🤖 Generated with Claude Code