Validate report API host arguments#842
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis PR centralizes API-host parsing by adding ChangesAPI Host Validation
Possibly related issues
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d2381118-b38f-4b1e-9a46-a3545b840ef3
📒 Files selected for processing (7)
scripts/api_host_args.pyscripts/claim_inventory.pyscripts/proposed_work_triage.pyscripts/submission_quality_gate.pytests/test_claim_inventory.pytests/test_proposed_work_triage.pytests/test_submission_quality_gate.py
jakerated-r
left a comment
There was a problem hiding this comment.
Reviewed current head 548794da737c04a11956cbef8901bc34515cf468 for bounty review scope.
What I checked:
- Inspected the new shared
scripts/api_host_args.pyvalidator and its wiring intoclaim_inventory.py,proposed_work_triage.py, andsubmission_quality_gate.py. - Verified invalid
--api-hostvalues now fail during argparse parsing before live GitHub/API collection for blank, relative, and non-HTTP(S) inputs. - Verified valid absolute hosts still work, including a trailing-slash smoke on
proposed_work_triage.py --api-host https://api.mrwk.online/. - Confirmed the existing
api_host.rstrip('/')URL construction is preserved in all three scripts. - Checked duplicate/saturation risk on #654: no existing human review or #654 claim for PR #842 before this review.
- Checked hosted status: Quality workflow SUCCESS, CodeRabbit SUCCESS, GitHub mergeStateStatus CLEAN.
Local validation:
uv run --extra dev pytest tests/test_proposed_work_triage.py tests/test_claim_inventory.py tests/test_submission_quality_gate.py -q-> 73 passeduv run --extra dev pytest -q-> 752 passed, 1 existing Starlette/httpx deprecation warninguv run --extra dev ruff format --check scripts/api_host_args.py scripts/claim_inventory.py scripts/proposed_work_triage.py scripts/submission_quality_gate.py tests/test_claim_inventory.py tests/test_proposed_work_triage.py tests/test_submission_quality_gate.py-> 7 files already formatteduv run --extra dev ruff check scripts/api_host_args.py scripts/claim_inventory.py scripts/proposed_work_triage.py scripts/submission_quality_gate.py tests/test_claim_inventory.py tests/test_proposed_work_triage.py tests/test_submission_quality_gate.py-> All checks passeduv run --extra dev mypy app-> Successgit diff origin/main...HEAD --check-> cleangit merge-tree $(git merge-base origin/main HEAD) origin/main HEAD-> completed without conflict markers
Non-blocking note: CodeRabbit's one actionable comment is only the redundant local import pytest in tests/test_proposed_work_triage.py; since it is test-only and harmless, I am not blocking on it.
jakerated-r
left a comment
There was a problem hiding this comment.
Follow-up current-head review after the cleanup commit.
Reviewed new head 25194c0dad91d7bf2f739cd776da9126c7a849a0, which only removes the redundant local import pytest from tests/test_proposed_work_triage.py. The prior API-host validation analysis still applies to the current head.
Current-head validation rerun:
uv run --extra dev pytest tests/test_proposed_work_triage.py tests/test_claim_inventory.py tests/test_submission_quality_gate.py -q-> 73 passeduv run --extra dev pytest -q-> 752 passed, 1 existing Starlette/httpx deprecation warninguv run --extra dev ruff format --check scripts/api_host_args.py scripts/claim_inventory.py scripts/proposed_work_triage.py scripts/submission_quality_gate.py tests/test_claim_inventory.py tests/test_proposed_work_triage.py tests/test_submission_quality_gate.py-> 7 files already formatteduv run --extra dev ruff check scripts/api_host_args.py scripts/claim_inventory.py scripts/proposed_work_triage.py scripts/submission_quality_gate.py tests/test_claim_inventory.py tests/test_proposed_work_triage.py tests/test_submission_quality_gate.py-> All checks passeduv run --extra dev mypy app-> Successgit diff origin/main...HEAD --check-> cleangit merge-tree $(git merge-base origin/main HEAD) origin/main HEAD-> completed without conflict markers- Valid-host smoke with
proposed_work_triage.py --api-host https://api.mrwk.online/still exits 0 and returns the expected summary keys.
No new findings from me on this head.
|
Maintainer queue status for #815/#799: held before merge/payment. Current head and checks are clean, #799 has live effective capacity, and this remains the implementation path for #815, but there is only one distinct useful current-head human reviewer. Needs a second useful current-head human review before acceptance. |
xiefuzheng713-alt
left a comment
There was a problem hiding this comment.
Reviewed current head 25194c0dad91d7bf2f739cd776da9126c7a849a0 as a non-author.
Scope inspected:
scripts/api_host_args.py: verified the sharedpublic_api_host()argparse type trims input, rejects empty/whitespace-only values, and requires an absolute HTTP(S) URL with a netloc before report tooling builds public API URLs.scripts/proposed_work_triage.py,scripts/claim_inventory.py, andscripts/submission_quality_gate.py: verified the new validator is applied only to--api-hostparsing and does not add GitHub mutations or change report analysis logic.tests/test_proposed_work_triage.py,tests/test_claim_inventory.py, andtests/test_submission_quality_gate.py: verified invalid host coverage for empty string, whitespace-only, relative path, and non-HTTP(S) URL.
Validation run on this head:
uv run --python 3.12 --extra dev python -m pytest tests/test_proposed_work_triage.py tests/test_claim_inventory.py tests/test_submission_quality_gate.py -q-> 73 passed.- CLI smoke:
python scripts/proposed_work_triage.py --repo ramimbo/mergework --limit 1 --api-host " " --format json-> exit 2 withapi host must be a non-empty HTTP(S) URL. - CLI smoke:
python scripts/claim_inventory.py --repo ramimbo/mergework --api-host /relative --format json-> exit 2 withapi host must be an absolute HTTP(S) URL. - CLI smoke:
python scripts/submission_quality_gate.py --text-file draft.md --api-host ftp://api.example.test --format json-> exit 2 withapi host must be an absolute HTTP(S) URL. uv run --python 3.12 --extra dev python -m pytest -q-> 752 passed, 1 existing Starlette/httpx warning.uv run --python 3.12 --extra dev ruff check scripts/api_host_args.py scripts/proposed_work_triage.py scripts/claim_inventory.py scripts/submission_quality_gate.py tests/test_proposed_work_triage.py tests/test_claim_inventory.py tests/test_submission_quality_gate.py-> passed.uv run --python 3.12 --extra dev ruff format --check scripts/api_host_args.py scripts/proposed_work_triage.py scripts/claim_inventory.py scripts/submission_quality_gate.py tests/test_proposed_work_triage.py tests/test_claim_inventory.py tests/test_submission_quality_gate.py-> 7 files already formatted.uv run --python 3.12 --extra dev mypy app-> success.uv run --python 3.12 --extra dev python scripts/docs_smoke.py-> docs smoke ok.git diff --check origin/main...HEAD-> clean.git merge-tree --write-tree origin/main HEAD-> clean treec5b1c4acfdb6e5711c377bd0be82e0e8c1c758d1.
Currentness and duplicate check: PR #842 is mergeable at the reviewed head with hosted Quality/readiness/docs/image and CodeRabbit checks passing. Before posting, I found one current-head human approval and the existing #654 claim comments were both from that same reviewer, so this is a second independent current-head review.
No blocker found. The change is limited to read-only report-script argument validation and does not touch GitHub label/comment mutation paths from the app, bounty creation, proposal execution, payout, ledger mutation, wallet behavior, private data, secrets, exchange, bridge, off-ramp, cash-out, or price behavior.
aglichandrap
left a comment
There was a problem hiding this comment.
Review evidence (head SHA: 25194c0dad91):
- ✅ Scope: Extracts
public_api_hostvalidator into sharedscripts/api_host_args.py, applies toclaim_inventory.py. - ✅ Validation: Checks for non-empty string,
http/httpsscheme, and non-empty netloc viaurllib.parse.urlparse. - ✅ Reusability: Shared module avoids duplicating validation across scripts.
- ✅ Argparse integration: Uses
type=public_api_hostfor automatic validation on--api-host. - ✅ Files: 7 files, +53/-3 — includes
proposed_work_triage.py,submission_quality_gate.py. - ✅ Mergeable: state=clean.
No blockers. Approve.
Summary
public_api_hostargparse validator for public report-tool API origins.--api-hostvalues before any live GitHub/API collection.proposed_work_triage.py,claim_inventory.py, andsubmission_quality_gate.pyas requested by source issue Proposed work: validate report API host arguments #815.Bounty #799
Source issue: #815
Evidence
#815 reports that report scripts can accept malformed API hosts and crash later while building public API URLs. The issue comment also points out that
submission_quality_gate.pyhas the same boundary and should share the validation helper.This PR keeps valid absolute HTTP(S) hosts working and only changes CLI argument validation for invalid hosts.
Validation
python -m pytest tests\test_proposed_work_triage.py tests\test_claim_inventory.py tests\test_submission_quality_gate.py -q-> 73 passedpython -m pytest -q-> 752 passed, 1 existing Starlette/httpx warningpython -m ruff format --check .-> 111 files already formattedpython -m ruff check .-> All checks passedpython -m mypy app-> Successgit diff --check-> cleanCLI smoke after the fix:
python scripts\proposed_work_triage.py --repo ramimbo/mergework --limit 1 --api-host " " --format json-> argparse error:api host must be a non-empty HTTP(S) URLpython scripts\claim_inventory.py --repo ramimbo/mergework --api-host /relative --format json-> argparse error:api host must be an absolute HTTP(S) URLpython scripts\submission_quality_gate.py --text-file draft.md --api-host ftp://api.example.test --format json-> argparse error:api host must be an absolute HTTP(S) URLScope and Safety
Summary by CodeRabbit
Bug Fixes
--api-hostargument and only accept absolute HTTP(S) URLs; empty, whitespace-only, relative, or non-HTTP(S) values produce clear parse-time errors.Tests
--api-hostvalues are rejected with appropriate exit codes and error messages.