Refactor request parsing helpers out of app.main#346
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR refactors request parsing helpers from ChangesRequest Parsing Module Extraction
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
TateLyman
left a comment
There was a problem hiding this comment.
No blockers from my pass.
Evidence checked:
- Inspected
app/request_parsing.py,app/main.py, andtests/test_request_parsing.pyagainst currentorigin/main. - Verified JSON body parsing, required/optional string parsing, integer parsing, positive bounty/ledger path validation, proof-hash normalization, and wallet-address normalization moved behind
app.request_parsingwhile preserving the sameHTTPExceptionstatus/details used by the route layer. - Verified route imports keep the old helper aliases in
app/main.py, so API, wallet, ledger, proof, admin, and MCP route call sites keep their existing behavior. - Verified new focused tests cover positive path ids, proof-hash normalization/rejection, string helper errors, and integer helper parsing/rejection.
- Hosted quality check is green; GitHub currently reports mergeState
UNSTABLEwhile CodeRabbit is still processing.
Validation:
uv run --extra dev python -m pytest tests/test_request_parsing.py tests/test_security.py tests/test_wallet_api.py -q-> 87 passed.uv run --extra dev python -m pytest -q-> 339 passed.uv run --extra dev ruff check app/main.py app/request_parsing.py tests/test_request_parsing.py-> passed.uv run --extra dev ruff format --check app/main.py app/request_parsing.py tests/test_request_parsing.py-> passed.uv run --extra dev python -m mypy app/main.py app/request_parsing.py-> passed.uv run --extra dev python scripts/docs_smoke.py-> docs smoke ok.git diff --check origin/main...HEAD-> clean.
aiautotool
left a comment
There was a problem hiding this comment.
No blockers found on current head 115feca.
Evidence summary:
- Inspected
app/request_parsing.py,app/main.py, andtests/test_request_parsing.py. - Verified the extracted path/body helpers preserve the existing HTTP 400 details for bounty IDs, ledger sequences, wallet addresses, proof hashes, invalid JSON bodies, missing string fields, and integer coercion.
- Checked that
parse_int()still rejects booleans separately from integers, trims signed numeric strings, and keepsNonehandling split between required/optional field helpers. - Confirmed
app.maincontinues to call the same helper names through private aliases, so route behavior stays unchanged while request parsing moves out of the large app module.
Validation:
uv run --extra dev python -m pytest tests/test_request_parsing.py tests/test_wallet_api.py::test_github_login_stores_safe_default_for_backslash_next -q-> 5 passed.uv run --extra dev ruff check app/main.py app/request_parsing.py tests/test_request_parsing.py-> passed.uv run --extra dev python -m mypy app/main.py app/request_parsing.py-> success.
No secrets, wallet private keys, payout credentials, private vulnerability details, deployment values, or MRWK price claims are included.
|
Maintainer note after #320 filled: this PR still references closed bounty #320. If you want it considered for the current code-health round, rebase against main, update the bounty reference to #377, and keep the scope distinct from already accepted #328, #337, #364, #375, and #376. This is not accepted or paid as-is. |
Summary
app/main.pyinto focusedapp/request_parsing.pyRefs #320
Complexity reduced
This moves JSON object parsing, required/optional field coercion, integer parsing, positive bounty/ledger path validation, proof hash normalization, and wallet-address HTTP error mapping behind one small request-parsing boundary.
app/main.pykeeps route wiring and auth/session helpers, while validation behavior can now be reviewed and tested independently.Validation
./.venv/bin/python -m pytest tests/test_request_parsing.py tests/test_security.py tests/test_wallet_api.py -q— 87 passed./.venv/bin/python -m pytest -q— 339 passed./.venv/bin/python scripts/docs_smoke.py— docs smoke ok./.venv/bin/python -m ruff format --check .— 50 files already formatted./.venv/bin/python -m ruff check .— all checks passed./.venv/bin/python -m mypy app— successgit diff --check— passedNo secrets, wallet private keys, payout credentials, private vulnerability details, deployment credentials, or MRWK price claims are included.
Summary by CodeRabbit
Refactor
Tests