Skip to content

Fail fast when the API reports a failed generation - #12

Merged
adhikjoshi merged 1 commit into
mainfrom
fix/fail-fast-on-generation-error
Sep 22, 2026
Merged

adhikjoshi merged 1 commit into
mainfrom
fix/fail-fast-on-generation-error

Conversation

@adhikjoshi

@adhikjoshi adhikjoshi commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Problem

The generation API reports a failed generation as HTTP 200 with status: "error" and no job id. pollAndDownload checked only for "success", so it:

  • polled fetch/ with an empty id, retrying each failed poll silently, and
  • exited with code 7 after the 5-minute timeout, printing a blank job id.

With --no-wait it printed Job 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:error form. Until now the client retried the 500 and then reported it.

Change

  • status of "error" or "failed" on the first response returns the API's message at once. Structured validation messages (objects) are JSON-encoded.
  • A non-success response without a job id is an error. It is never polled.
  • The poll loop uses the same message handling.

Tests

  • New internal/cmd/generate_poll_test.go covers: an error with and without --no-wait (must return within 1 s, with no polling), a structured validation message, and a missing job id.
  • These tests fail on main, where the command polls until the timeout.
  • go test ./... passes.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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.
@adhikjoshi
adhikjoshi merged commit 733fe37 into main Sep 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant