Repository navigation
fix(bfl): read the task status from non-2xx poll responses - #566
Closed
Kamilbenkirane wants to merge 1 commit into
Closed
Kamilbenkirane wants to merge 1 commit into
Kamilbenkirane wants to merge 1 commit into
Conversation
BFL can return a failed FLUX 3 task as HTTP 503 with a normal JSON body. The poll loop raised the HTTP error before reading that body, so a failed task surfaced as an httpx.HTTPStatusError instead of the ValueError that names its status. The loop now reads the JSON status first and keeps the HTTP error for responses without a terminal status.
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.
A failed BFL task can come back from the poll endpoint as a non-2xx response with its status in the JSON body.
BFLImagesClient._make_requestcalled_handle_error_responsebefore reading that body, so such a task raisedhttpx.HTTPStatusError("bfl API error: {...}"). It should raise theValueErrorthat names the BFL status, as the loop already does forError, moderation,No Card Generated(#512) andTask not found. Two BFL pages document this:503with a normal JSON body. Readstatusfrom the body before treating a503as a retryable outage."status: "Error", and an explanation indetails.error."The
get_resultschema in the OpenAPI spec (ResultResponse:id,status,result,progress,details) is the body these responses carry.Fix:
src/celeste/providers/bfl/images/client.py,BFLImagesClient._make_request: the poll loop now parses the JSON body first and checksReadyand the existing terminal statuses. It calls_handle_error_responseonly after those checks.ValueError, with the status anderror/details.httpx.HTTPStatusErroras before: a non-JSON outage page,{"detail": ...}, a 429, or an in-progress status.JSONDecodeError. The status list and messages are unchanged.Overlap: draft #524 renames this file to
providers/bfl/flux/client.pyand #521 builds on it.git merge-treeshows this change applies to both branches without conflicts.Validation:
make cipasses: Ruff, format, mypy, Bandit, 744 unit tests.Live:
test_generate[bfl-flux-2-klein-4b-parameters3]passes on this branch (POST https://api.bfl.ai/v1/flux-2-klein-4b,aspect_ratio256x1024, polled toReady).Local, uncommitted, with stubbed poll responses:
main{"status":"Error","details":{...}}HTTPStatusErrorValueError: bfl image generation failed (Error): {...}{"status":"Error",...}HTTPStatusErrorValueError{"detail":...}, 500{"status":"Pending"}HTTPStatusErrorHTTPStatusError(unchanged)Pending, thenReadyThere is no unit test. One would have to stub the transport, and house rules keep that to
tests/unit_tests/test_http.py.CHANGELOG is unchanged, following the fix PRs merged since the
v1.0.0tag (fix(bfl): add match_input to the flux-3-image quality choices #548–fix(openai): remove the shut-down gpt-image-1 registration #553).