Add shared public JSON fetch helper for maintenance scripts (#1144)#1174
Add shared public JSON fetch helper for maintenance scripts (#1144)#1174yanyishuai wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 57 minutes and 52 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 credits. 🚦 How do rate 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 see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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 |
qingfeng312
left a comment
There was a problem hiding this comment.
Finding:
- [P1] Fix the ruff failures introduced by the new public JSON helper before merge. The current head
31692e94afc796a6256c17d084ab5c038acf3b05passes pytest (911 passed, 1 warning), but CI fails atruff check .with six issues:scripts/claim_inventory.pystill imports unusedurllib.request, its local script imports are unsorted,tests/test_public_json_fetch.pyhas a quoted_FakeResponsereturn annotation, and three nestedwith patch(...): with pytest.raises(...)blocks triggerSIM117. Please remove the stale import, organize the imports, and apply the test-style cleanups so the lint gate passes.
Evidence checked:
- PR #1174 is open, non-draft, and authored by another account.
- Inspected
scripts/claim_inventory.py,scripts/public_json_fetch.py, andtests/test_public_json_fetch.py. - Checked CI run
28329923637: pytest passed, formatting passed, thenruff check .failed with the listed errors.
Scope boundary: review evidence only. No wallet signing, treasury mutation, payout execution, exchange, bridge, private data, credentials, or secrets involved.
31692e9 to
4038298
Compare
|
@qingfeng312 Ruff issues fixed.
Latest head: |
|
@qingfeng312 CI is green on the latest head ( |
1 similar comment
|
@qingfeng312 CI is green on the latest head ( |
qingfeng312
left a comment
There was a problem hiding this comment.
Follow-up on current head 40382987dbf7bebd1f75ce85981c3d6f88297799.
The earlier Ruff lint blocker has been resolved. I rechecked scripts/public_json_fetch.py, the claim_inventory migration, and tests/test_public_json_fetch.py.
The new helper centralizes public JSON fetching without changing the existing _get_json caller contract, preserves the timeout wiring, and covers HTTP, timeout, invalid JSON, custom timeout, and header behavior in focused tests.
Validation checked: GitHub CI Quality, readiness, docs, and image checks passed on run 28349126882; CodeRabbit status is success on this head. I did not find a remaining blocker for the scoped #1144 change.
Summary
Adds
scripts/public_json_fetch.pyexposing oneload_public_jsonhelper plus aPublicJsonErrorfor read-only public JSON fetches. Migratesscripts/claim_inventory.pyto call the new helper while preserving its existing_get_jsonwrapper (callers see no behaviour change). Addstests/test_public_json_fetch.pycovering the happy path, default headers, HTTP error, timeout, invalid JSON, and custom timeout.Why
Five maintenance scripts (
claim_inventory,submission_quality_gate,proposed_work_triage,check_bounty_issue_states,check_live_bounty_closing_refs) each implemented their own small public-JSON fetch helper aroundurllib.request.urlopen. They did not agree onAcceptheaders, timeout values, or error wording. A future bugfix to any of those details had to be copy-pasted across files and the error wording silently diverged. This PR ships the helper plus one concrete migration so the contract is proven on a real caller; the remaining scripts can be migrated in follow-up PRs.Behavior
load_public_json(url, description=None, timeout=30, user_agent="mergework-maintenance-script", accept="application/json") -> Any.PublicJsonErrorraised on HTTP error, network/timeout failure, or invalid JSON, with a uniform "{description} unavailable: ..." message.scripts/claim_inventory.py::_get_jsonnow delegates toload_public_jsonand threads the existingGH_TIMEOUT_SECONDSconstant.Tests
tests/test_public_json_fetch.py(6 cases).Out of scope
Closes #1144
Solana wallet for bounty payout:
Do4v7foHJvRJLpRRoGaVPWX6DDEjX3yTK7J91gpwUQpE