Skip to content

diag(byoc): surface real signer error behind opaque IncompleteRead(85, 108)#38

Open
seanhanca wants to merge 1 commit into
mainfrom
diag/byoc-signer-truncation-error
Open

diag(byoc): surface real signer error behind opaque IncompleteRead(85, 108)#38
seanhanca wants to merge 1 commit into
mainfrom
diag/byoc-signer-truncation-error

Conversation

@seanhanca

Copy link
Copy Markdown
Contributor

What & why

Diagnostic-only change. During a billed E2E run, BYOC payment fails inside _create_byoc_payment (src/livepeer_gateway/byoc.py) when reading the signer response from /generate-live-payment.

The signer advertises a Content-Length (~193 bytes) but closes the connection after delivering only ~85 bytes. urllib then raises:

http.client.IncompleteRead(85 bytes read, 108 more expected)

Because urllib discards the partial body on IncompleteRead, we lose the real signer error payload ({"error":{"message":"..."}}) and are left blind — the failure surfaces as an opaque IncompleteRead(85, 108) with zero diagnostic value.

Change

  • Add import http.client.
  • In _create_byoc_payment, catch http.client.IncompleteRead on the response read and re-raise the partial bytes inside the existing LivepeerGatewayError, so the underlying signer error becomes legible.
  • Guard the existing HTTPError path against a truncated error body too (keep whatever bytes arrived rather than losing the message entirely).

This is low-risk: control flow is unchanged (it still funnels into the same except/LivepeerGatewayError handling at the call site) — only the error message improves.

What this does NOT do

This does not fix payment generation or unblock generation. The root cause is the signer/DMZ truncating its response (likely a wallet/ticket panic mid-write). That fix belongs to @j0sh's DMZ wallet/image work. This PR only makes the failure legible so the real signer error can be read from logs.

Context

  • Reproduces on Runs 13–16 of a billed E2E, all failing at the BYOC payment step.
  • Signer endpoint: .../generate-live-payment (behind the DMZ).

Test plan

  • python -m py_compile src/livepeer_gateway/byoc.py
  • Existing suite green: pytest tests/ → 9 passed.
  • Added tests/test_byoc_payment_truncation.py (2 tests) — asserts a truncated 200 and a truncated error-status body both surface the partial signer body in the raised LivepeerGatewayError. Full suite → 11 passed.
  • Re-run the billed E2E → the BYOC failure now shows the real signer error body (e.g. wallet/ticket panic message) instead of IncompleteRead(85, 108).

Base branch note

_create_byoc_payment with the /generate-live-payment logic lives on main (and is mirrored across several feature branches). Based on main since that is where this code path currently resides; no dedicated WIP branch owns it.

cc @j0sh for review (repo CODEOWNER).

Made with Cursor

…pleteRead

When the remote signer (/generate-live-payment) advertises a Content-Length
but closes the connection early, urllib raises http.client.IncompleteRead and
discards the partial body. That body carries the real signer error
(e.g. {"error":{"message":"..."}}), so the failure surfaces as an opaque
"IncompleteRead(85 bytes read, 108 more expected)" with no diagnostic value.

Capture the partial bytes in _create_byoc_payment and re-raise them inside the
existing LivepeerGatewayError so the underlying signer failure is legible. Also
guard the HTTPError path against a truncated error body.

Diagnostic only: does not change control flow (still funnels into existing
except handling at the call site) and does not fix payment generation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@seanhanca seanhanca requested a review from j0sh as a code owner July 9, 2026 05:14
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seanhanca, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: adbe64b5-dee4-4ea1-ba98-926750bd8c8f

📥 Commits

Reviewing files that changed from the base of the PR and between cc31b56 and aff1627.

📒 Files selected for processing (2)
  • src/livepeer_gateway/byoc.py
  • tests/test_byoc_payment_truncation.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch diag/byoc-signer-truncation-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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