Fail fast when the API reports a failed generation - #12
Merged
Merged
Conversation
The API reports a failed generation as HTTP 200 with status "error" and no job id. pollAndDownload only looked for "success", so it went on to poll fetch/ with an empty id: every poll errored, was retried silently, and the command exited 7 after the 5-minute timeout with a blank job id. With --no-wait it printed "Job queued" for a job that never existed. The API is about to answer provider refusals on the generation routes this way too (they were HTTP 500, which the client retried and then reported). pollAndDownload now returns the API's message at once for "error"/"failed", including structured validation messages, and refuses to poll without a job id. The poll loop reuses the same message handling.
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
The generation API reports a failed generation as HTTP 200 with
status: "error"and no job id.pollAndDownloadchecked only for"success", so it:fetch/with an empty id, retrying each failed poll silently, andWith
--no-waitit printedJob queued:for a job that never existed.This matters now: ModelsLab/modelslab-frontend-v2 is changing provider refusals on the generation routes from HTTP 500 to this 200
status:errorform. Until now the client retried the 500 and then reported it.Change
statusof"error"or"failed"on the first response returns the API's message at once. Structured validation messages (objects) are JSON-encoded.Tests
internal/cmd/generate_poll_test.gocovers: an error with and without--no-wait(must return within 1 s, with no polling), a structured validation message, and a missing job id.main, where the command polls until the timeout.go test ./...passes.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.