Repository navigation
Stop retrying into a rate-limit block and name the request budgets - #243
Merged
Merged
Conversation
A 429 is a spent request budget: the API counts 500 requests/10s per token and
gumroad.com counts 6,000 requests/hour per IP, so a --all walk can spend one by
itself. Two 600ms retries inside a block only burn more of it, and the old hint
('Wait a moment and retry') sent a seller whose IP was banned for an hour back
into the same loop.
- A 429 naming a Retry-After longer than 5s is reported at once, carrying the wait.
- A 429 with no wait backs off 1s then 2s before giving up.
- The 429 hint names both limits and points at 'sales export' for whole histories.
- skills/gumroad/SKILL.md replaces the '--page-delay 200ms avoids rate limits' tip
with the page/request arithmetic and the export alternative.
TastelintThe only picture is a blank terminal frame with a cursor, not a user interface, so there is nothing here for me to review. |
gumclaw
added a commit
to antiwork/gumroad
that referenced
this pull request
Nov 17, 2026
Part of antiwork/gumroad-private#4761 ## What `GET /v2/sales` returns 100 sales per page instead of 10, and the API docs say so. ```diff - RESULTS_PER_PAGE = 10 + RESULTS_PER_PAGE = 100 ``` ## Why A seller with 59,425 sales walked their own history with `gumroad sales list --all` and got their IP rate-limited mid-run: Cloudflare 1015, Ray `a5bc697d6e41c519`, after 6,836 `GET /v2/sales` requests, every one of them a 200 until the zone rule "6000 requests / 1 hour" tripped. At 10 sales per page that history is ~5,942 requests, so a single walk of a large account spends the entire hourly edge budget on pagination alone. At 100 it is ~594. 100 is what `Api::V2::SubscribersController` already returns, so this brings the sales endpoint in line with its sibling rather than inventing a new number. The page-key contract does not change: responses still carry `next_page_key`, and `MAX_DEPRECATED_PAGE` stays derived from `RESULTS_PER_PAGE`, so the offset ceiling follows. ## Evidence — this branch, lane 0, seeded QA seller with 130 sales **Two requests instead of thirteen** (`localhost:3000`, `curl -H "Authorization: Bearer …" /v2/sales`):  Page 1 → `sales_on_page: 100, more_pages: true`. Page 2 (`page_key` from the response) → `sales_on_page: 30, more_pages: false`. On `main` the same 130 rows take 13 requests at 10 per page. **Docs sentence on the live local page** (`http://localhost:3000/api#get-/sales`):  `page_key (optional) - A key representing a page of results. It is given in the response as next_page_key. Each page holds up to 100 sales.` Before this change the row said nothing about how many sales a page holds. ## Tests - `CI=1 DISABLE_SPRING=1 bin/rspec spec/controllers/api/v2/sales_controller_spec.rb` → all examples pass. - `spec/controllers/api/v2/sales_controller_spec.rb:455` is new: it asserts a full page comes back and that the documented size is the shipped one, so the docs cannot drift from the constant again. - The pagination example stubs `RESULTS_PER_PAGE` to 4 (`stub_const`) so the fixtures stay cheap; the offset-ceiling example now derives its page number from `MAX_DEPRECATED_PAGE` instead of hardcoding the value that 10 per page happened to produce. ## Risk - Responses are up to 10x larger per request: on the seeded seller above, a 100-sale page is 145 KB, about 1.5 KB per sale, so a page was roughly a tenth of that before. That is the intended trade — 10x fewer round trips — and it matches the subscribers endpoint that already returns 100. - Additive-compatible for clients: `next_page_key`, field shapes and ordering are unchanged; only the number of rows per page moves. The paired CLI change (antiwork/gumroad-cli#243) quotes the new page size in `skills/gumroad/SKILL.md` and stops the CLI from retrying into a spent budget; it works against the API as deployed today, so the two can land in either order. Marketing: exempt (changes how many rows one API page returns plus one docs sentence; nothing to announce) @ 8fe8494 Premerge review: clean @ 8fe8494 --- AI disclosure: produced by an autonomous Gumclaw agent (Hermes; model `deepseek-v4.1-flash-1017`) from the instruction "Yes fix both", after tracing a seller's Cloudflare 1015 back to the page size. The evidence above was captured from this branch running locally. Co-authored-by: gumclaw <gumclaw@users.noreply.github.com>
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.
What
429that names aRetry-Afterlonger than 5s is reported at once instead of retried, and the error carries the wait.429with noRetry-Afterbacks off 1s then 2s (was 200ms then 400ms) before giving up.429error names both request budgets and the one-request alternative:gumroad sales export.skills/gumroad/SKILL.md: the--page-delay 200mstip is replaced. It spaces requests out but does not reduce how many there are, so it never prevented a walk from spending a budget. The replacement states the arithmetic (one request per page, 100 sales per page, ~600 requests for a 60k-sale history) and points atsales exportfor whole histories.Why
A seller with ~60k sales read their whole history with
--alland got their IP blocked with a Cloudflare 1015 mid-run: 6,836GET /v2/salesrequests, every one a 200 until the zone rule "6000 requests / 1 hour" tripped. The walk itself was not misbehaving — at 10 sales per page it was the only way to read a 59k-sale history (antiwork/gumroad#9202 pages 100 at a time, turning it into ~600 requests) — but the CLI's behaviour on the429made it worse in two ways: two retries inside 600ms, each one more request against an IP that is already blocked, and thenHint: Wait a moment and retry.An edge block lasts until the hourly window drains, so that hint is a loop.Before/After
429, noRetry-After(what the edge sends on a 1015)Hint: Wait a moment and retry.sales export429withRetry-After: 120200Demo
Demo shows a local mock edge answering every GET with a
429and the Cloudflare 1015 page (noRetry-After), the old binary, the new binary, and the same command against a200from the same endpoint. It runs entirely against the mock, so nothing in it depends on the paired API change.Tests
internal/api/client_test.go:TestClient_GetStopsOnRateLimitThatNamesALongWait(1 attempt,RetryAfter2m, the rate-limit hint) andTestClient_GetBacksOffInSecondsOnRateLimitWithoutAWait(3 attempts, sleeps 1s then 2s).internal/api/errors_test.go: both 429 rows ofTestAPIError_Hintsassert the sharedHintRateLimited.go test ./internal/api/ -count=1→ok ... 1.327s;go vet ./internal/...clean;gofmt -l internal/apiempty.go test ./...still failsTestUserJSONandTestUserJSONErrorWhenNotAuthenticatedin./test; both fail identically in a cleanorigin/mainworktree (they need a live token), so they are not from this change.AI disclosure: produced by an autonomous Gumclaw agent (Hermes; model
deepseek-v4.1-flash-1017) from the instruction "Yes fix both" after a seller reported a Cloudflare 1015 while walking their customer list. The incident analysis, the change, and the tests above came from that session.Marketing: exempt (fixes how the CLI reports a 429 and its help text; nothing to announce) @ b7bf842
Premerge review: clean @ b7bf842
Part of antiwork/gumroad-private#4761