fix(byoc): signer error bodies must never mask the status code - #66
Open
seanhanca wants to merge 1 commit into
Open
fix(byoc): signer error bodies must never mask the status code#66seanhanca wants to merge 1 commit into
seanhanca wants to merge 1 commit into
Conversation
When the signer rejects a dead API key at /generate-live-payment with 401, it answers before consuming the multi-KB POST body (base64 OrchestratorInfo) and closes the connection. The client's buffered response can then be truncated, so e.read() inside the except-HTTPError handler raises http.client.IncompleteRead — which escapes the handler and surfaces as 'payment failed: IncompleteRead(84 bytes read, 109 more expected)' with no trace of the 401. Downstream classifiers read that as a transient GPU outage and users burn retries against a permanently dead key (live incident 2026-08-21, cjob_0a9056941b2a; 84+109 = the signer's exact 193-byte AUTH/FAILED body). - New _read_http_error_body(): reads the body defensively, salvaging IncompleteRead.partial, never raising. Used at all five HTTPError sites (the two signer paths were fully naked; the three orch paths kept the status but dropped the body on a truncated read). - The signer paths now lead with the status and name the failure: 'signer rejected key: HTTP 401: <body>'. 403 keeps its existing message shape — downstream out-of-credits classifiers match on it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| """ | ||
|
|
||
| import io | ||
| import json |
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
Diagnosing failed creative job
cjob_0a9056941b2a(2026-08-21): when the signer rejects a dead Daydream key at/generate-live-paymentwith HTTP 401 (193-byteAUTH/FAILEDJSON body), the SDK surfaces:84 + 109 = 193 — the signer's exact body size. Mechanism (reproduced): the signer answers 401 before consuming the multi-KB POST body (base64 OrchestratorInfo) and closes the connection; the reset can truncate the client's buffered response, so
e.read()inside theexcept HTTPErrorhandler raiseshttp.client.IncompleteRead, which escapes the handler — the 401 status never reaches the message. (With a very large body the same race lands as an SSL EOF during upload; at real payload sizes it lands as this truncated read.)Downstream,
payment failed: IncompleteRead(...)classified as "GPU network briefly busy — retry" — the opposite of a permanent per-key auth failure.Fix
_read_http_error_body(e, limit)— defensive body read: salvagesIncompleteRead.partial(the first 84 bytes contain"Authentication failed","code":"AUTH/FAILED"— plenty), never raises. Applied at all fiveHTTPErrorsites: the two signer paths (_create_byoc_payment,_sign_byoc_job) were fully naked; the three orch paths kept the status but dropped the body on truncation.signer rejected key: HTTP 401: <body>so error classifiers can distinguish a dead key from an outage. 403 keeps its existing message shape (BYOC payment generation failed: HTTP 403: ...) — the storyboard-side out-of-credits classifier matches on it.Verification
tests/test_http_error_body.py: 7 new tests — helper salvage/never-raise/limit, plus end-to-end through_sign_byoc_job's real except-handler with a body whose read raisesIncompleteReadmid-flight (assertssigner rejected key+HTTP 401in the message, and that 403/500 shapes are unchanged).Companion PR: livepeer/storyboard#1102 maps both the legacy IncompleteRead mask and this new explicit shape to
payment_unauthorized(non-retryable).🤖 Generated with Claude Code