fix(amux): detect nested data.status in async video poll#14
Merged
Conversation
The universal video poll endpoint (`GET /v1/video/generations/{task_id}`)
returns `{ code, message, data: { status, url, error } }`, and reports
terminal success as `"succeeded"` — but `poll_async_result` read the
root-level `status` and only matched `"completed"`. The status string was
therefore always empty, the loop never recognized completion, and every
Doubao-Seedance generation polled until the 3600s budget elapsed and then
errored `"did not complete within 3600s"` — even though the video had
rendered successfully (and was billed upstream).
Read the status from `data.status` (falling back to the root for a flat
shape) and accept `"succeeded"`/`"completed"` as success and
`"failed"`/`"error"` as failure, pulling the reason from `data.error`.
`parse_urls` already handled `data.url`, so URL extraction works once the
loop terminates. Extracted the classification into a pure `classify_poll`
helper with unit tests covering the nested succeeded/failed shapes, the
pending states, and the flat-shape fallback.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
I have read the Contributor License Agreement (CLA) and hereby sign the CLA. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every Doubao-Seedance video generation polled amux for the full
ASYNC_TASK_TIMEOUT(3600s) and then failed withdid not complete within 3600s— even though the render succeeded on amux's side (and was billed upstream, ~87k tokens per discarded task).Root cause
The universal poll endpoint
GET /v1/video/generations/{task_id}returns:{"code":"success","data":{"status":"succeeded","url":"https://cdn.amux.ai/…mp4"}}But
poll_async_resultread the root-levelstatusand only matched"completed":data.status→ root read was alwaysNone/"""succeeded", not"completed"So the loop never hit a terminal arm and ran to the timeout.
parse_urlsalready handleddata.url, so only the status detection was broken.Fix
data.status, falling back to the root for a flat shape."succeeded"/"completed"(Done) and"failed"/"error"(Failed), reading the reason fromdata.error.message.classify_pollhelper with unit tests: nestedsucceeded, nestedfailedw/ reason, pending states (queued/in_progress/unknown/empty), and the flat-shape fallback. Also aparse_urlstest fordata.url.Verified against the real captured amux response.
cargo check -p tensorzero-core+clippyare clean.🤖 Generated with Claude Code