fix: fail fast on signer HTTP 483 insufficient balance#44
Conversation
Map signer 483 to InsufficientBalance and skip orchestrator fallback for LV2V/BYOC payment failures. Also add package LOG_LEVEL configure_logging.
📝 WalkthroughWalkthroughThe gateway adds ChangesGateway behavior and runtime setup
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Signer
participant request_json
participant payment_session
participant start_lv2v
participant OrchestratorCandidates
Signer-->>request_json: HTTP 483 response
request_json-->>payment_session: InsufficientBalance
payment_session-->>start_lv2v: propagate exception
start_lv2v-->>OrchestratorCandidates: stop fallback
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Keep this branch scoped to HTTP 483 / InsufficientBalance fail-fast only.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/livepeer_gateway/byoc.py`:
- Around line 402-403: Update _create_byoc_payment to detect HTTP 483 responses
and raise InsufficientBalance while preserving the response details; continue
wrapping other HTTPError cases as LivepeerGatewayError. This enables the
InsufficientBalance handlers at src/livepeer_gateway/byoc.py lines 402-403 and
688-689 to execute; both sites require no direct change.
In `@src/livepeer_gateway/logging_config.py`:
- Around line 12-31: Update _resolve_level so an omitted level and unset
LOG_LEVEL resolve to logging.NOTSET, allowing the package logger to inherit the
parent/root logger level instead of forcing INFO on import. Preserve explicit
argument and environment values, and keep configure_logging’s explicit setup
default at INFO by applying that default before calling _resolve_level when no
level is provided.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 996bc0a7-917e-4f18-b969-35cfdef75a07
📒 Files selected for processing (8)
examples/write_frames.pysrc/livepeer_gateway/__init__.pysrc/livepeer_gateway/byoc.pysrc/livepeer_gateway/errors.pysrc/livepeer_gateway/logging_config.pysrc/livepeer_gateway/lv2v.pysrc/livepeer_gateway/orchestrator.pytests/test_insufficient_balance.py
Let HTTP 483 reach the existing fail-fast handlers instead of wrapping it as a generic payment failure.
|
@j0sh Do you think it's alright to reuse HTTP 483 here for the balance gate? It allows identity-webhook to signal payment required. The clearinghouse returns a 402 status code internally, but only the webhook sees it and it seems that go-livepeer expects specific status codes back |
Summary
InsufficientBalanceerrorTest plan
pytest tests/test_insufficient_balance.py -qInsufficientBalanceimmediately (no second orch attempt)Response from signer when
-remoteSignerWebhookUrlreturns 402 status code