refactor: consolidate refuse-redirect handlers into shared comfy_cli/http.py (BE-2152)#487
refactor: consolidate refuse-redirect handlers into shared comfy_cli/http.py (BE-2152)#487mattmillerai wants to merge 1 commit into
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review 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 refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
…http.py (BE-2152)
18c9348 to
2aa8c89
Compare
ELI-5
Five different files each had their own private copy of the same little safety class that says "if a server tries to redirect this authenticated request somewhere else, refuse — don't hand over the
Bearertoken /X-API-Keyto wherever it points." Five identical copies means a future security fix could land in one and be forgotten in the other four. This PR replaces all five with one audited definition in a newcomfy_cli/http.py, so there's a single source of truth.What changed
comfy_cli/http.py— oneNoRedirectHandler(stdlib-only, so no import cycles). It refuses to follow any 30x redirect and raises a clearHTTPErrorinstead. The refusalmessageis a constructor arg so call sites keep their own wording.comfy_client.py(_NoRedirectHandler)cql/engine.py(_NoRedirectHandler)cql/loader.py(_NoRedirect)cloud/oauth.py(_NoRedirect)command/transfer.py(_NoRedirectHandler) — passes"redirect refused (auth leak prevention)"to preserve its original message byte-for-byte.tests/comfy_cli/test_http.py— assert every redirect status (301/302/303/307/308) raisesHTTPErrorwith the code preserved, the default"redirect refused"message, and a custom message passed through.Deliberately NOT touched
command/transfer.py's_DownloadRedirectHandler/_DOWNLOAD_OPENER— that one intentionally follows redirects while stripping auth headers (for cloud/api/view→ signed-GCS 302s). It is a distinct handler, not a duplicate. Left entirely alone._LOOPBACK_HOSTSduplication — out of scope for this ticket.Behavior
Pure refactor — no behavior change. All four non-transfer sites already used the message
"redirect refused"(now the default); transfer's longer message is preserved via the constructor arg. No import removals were needed (every file that keptimport urllib.errorstill uses it elsewhere).Verification
ruff check+ruff format --checkclean (ruff v0.15.15, matching the repo's pre-commit pin).pytestsuite: 2324 passed, 36 skipped.Judgment calls
http.py(the ticket calls for deleting the local classes; the shared docstring captures the auth-leak/SSRF reasoning).