Repository navigation
fix(api): reject non-object JSON bodies across bridge, scraper detective, and x402 endpoints - #2269
Merged
Scottcjn merged 2 commits intoSep 18, 2026
Conversation
… detective, and x402 routes
This was referenced Sep 17, 2026
Scottcjn
approved these changes
Sep 18, 2026
Scottcjn
left a comment
Owner
There was a problem hiding this comment.
Approved. All 25 new tests fail on main and pass here. Note that only the x402 routes are live: wrtc_bridge.py and scraper_detective's scraper_bp aren't registered by bottube_server (it imports wrtc_bridge_blueprint), so most of this hardens code that isn't served. Still correct.
Owner
RTC Reward (sent manually)The automatic merge reward for this PR failed silently: our reward workflow's credentials had gone stale (being fixed now; failures are also now announced on the PR instead of passing silently). We've now paid it by hand: 2 RTC, pending_id 4671 (24h hold, then confirmed). Sorry for the delay, @Cid-oe, and thank you for the contribution. — Sophia Elya |
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.
Summary
Follow-up to #2262 and issue Scottcjn/rustchain-bounties#16976:
request.get_json(silent=True) or {}only replaces falsy parse results. Truthy non-dict JSON bodies (lists, numbers, strings, booleans) survive theor {}and trigger an unhandled 500 (AttributeError: 'list' object has no attribute 'get') when.get()is subsequently called on them.This PR adds standardized object-body shape guards returning deterministic
400with{"error": "JSON body must be an object"}across:wrtc_bridge.py:POST /api/bridge/depositPOST /api/bridge/withdraw(along with robust float conversion for amount)scraper_detective.py:POST /api/admin/scrapers/blockPOST /api/admin/scrapers/unblockbottube_x402.py:POST /api/agents/me/coinbase-walletVerification
tests/test_json_object_body_guards.pycovering all 5 endpoints against truthy non-dict JSON payloads ([1, 2, 3],"just-a-string",42,3.14,True).pytest tests/test_json_object_body_guards.py -v-> 25 passed.pytest tests/test_wrtc_bridge_py_debit_rtc_toctou_poc.py tests/test_scraper_detective_bt_proof.py -v-> 6 passed.Disclosed wallet:
RTC8b1fb717791b0a7b72649342b5c7c7bd822786af