Repository navigation
docs(errors): list rate_limited explicitly as the fourth code both surfaces share - #210
Open
mattmillerai wants to merge 2 commits into
Open
mattmillerai wants to merge 2 commits into
mattmillerai wants to merge 2 commits into
Conversation
…rfaces share A v2 envelope rate_limited already reached router_exceptions.RateLimited through _class_for's fall-through to _BY_ERROR_TYPE. Name it in _BY_CODE beside unauthorized/forbidden/insufficient_credits, re-export it from comfy_sdk.exceptions, and update the README and docstrings that said three. No change to which class is raised.
|
Warning Review limit reached
This review includes 5 billable files and costs up to $1.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 56 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Your 132 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (5)
Comment |
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 3 finding(s).
| Severity | Count |
|---|---|
| 🟢 Low | 1 |
| ⚪ Nit | 2 |
Panel: 6/6 reviewers contributed findings.
…t, fix _BY_CODE comment
This branch has not been deployed
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.
ELI-5
When the jobs/assets API says "you're making requests too fast" (
rate_limited), the SDK already raisedcomfy_sdk.router_exceptions.RateLimited— but only because a lookup in one table missed and it fell through to a second one. This PR writes that mapping down on purpose, in the first table, next to the three other codes that work the same way, and fixes the docs that still said "three". What gets raised doesn't change.What changed
src/comfy_sdk/exceptions.py:"rate_limited": RateLimitedadded to_BY_CODE(next toinsufficient_credits),RateLimitedimported from.router_exceptionsand added to__all__(sorted) as the other shared classes are. The_BY_CODEcomment,_class_forstep 1, theto_sdk_errorcomment and the__all__comment now say four, and the_BY_CODEcomment says why: the v2 contract's account rate limit (components/responses/RateLimited) and Router'srate_limitedbucket are the same windowed allowance spelled the same way, so one class serves both and.error_type == "rate_limited"is set from either surface.src/comfy_sdk/router_exceptions.py: module docstring names four shared buckets includingrate_limited;RateLimited's docstring keeps the Router meaning and theConcurrencyLimitExceededcontrast, adds the v2 jobs/assets use, and narrows "detailnames the window" to the Router surface._spec_meaning_digestuntouched (it hashes the Router spec'smeaning, not this docstring;test_router_spec_contract.pyandcheck_drift.pyboth pass).README.md: the shared-names paragraph lists four and says a jobs/assets call throttled with429 rate_limitedraisesRateLimited; the "never reached Router → plainComfyError" sentence gets a clause for responses that land on one of the four shared codes — a v2 envelope naming one, or a bare401/402/403the status table maps to one — soexcept RouterErrorfiring is not by itself proof Router answered.tests/test_error_mapping.py:rate_limitedadded totest_a_bucket_both_surfaces_spell_keeps_its_v2_class; newtest_a_v2_envelope_rate_limited_is_the_shared_router_class(noerror_type, asserts exact type,RouterErrorancestry,code,error_type,retry_after), with a comment marking the sharing as deliberate.CHANGELOG.md: one bullet in Unreleased's existing### Changedsection.Judgment calls
comfy_sdkre-exportsUnauthorized/Forbidden/InsufficientCreditsat the root, but its own comment says per-bucket Router classes stay incomfy_sdk.router_exceptions; addingcomfy_sdk.RateLimitedwould be new public surface, which is out of scope. The README says so explicitly ("and the first three bycomfy_sdktoo").rate_limitedremoved fromtest_a_router_only_bucket_raises_its_typed_class. It's no longer a Router-only bucket, so leaving it there would make that test's name wrong. Its assertions (exact type,code,http_status,retry_after == 7at 429) are all covered again by the new test, so no coverage is lost.### Changedsection rather than a second heading. It also mentions the newcomfy_sdk.exceptions.RateLimitedre-export.Residual
tests/test_head_refusal.pyand theHEAD /assets/by-hash429 synthesis belong to open PR fix(assets): read a bodiless HEAD 429 on the by-hash probe as rate_limited, not queue_full #208 and weren't touched or run here (that file doesn't exist onmain). When fix(assets): read a bodiless HEAD 429 on the by-hash probe as rate_limited, not queue_full #208 lands, itstype(exc) is RateLimitedassertion now resolves through_BY_CODEinstead of the fall-through. Same class, so no change is expected._BY_CODElines. Expect a trivial merge conflict on adjacent dict lines, nothing semantic.main: removing the new_BY_CODEentry still passes because the fall-through gives the same class. The proof that behavior didn't change is thattests/test_job_metadata.py(which already pins v2rate_limited→RateLimited) passes unmodified.tests/integration/test_gateway_e2e.pyskips without live credentials, so it wasn't exercised.Provenance
ruff check,ruff format --check,mypy srcall cleancomfy_low.errors._CODE_BY_STATUS(401/402/403 map to the shared codes; 429 maps toqueue_full, notrate_limited)build-check, codegen drift (no generated or spec file touched)