Skip to content

Stop retrying into a rate-limit block and name the request budgets - #243

Merged
gumclaw merged 1 commit into
mainfrom
gumclaw/gp4761-sales-429
Nov 17, 2026
Merged

gumclaw merged 1 commit into
mainfrom
gumclaw/gp4761-sales-429

Conversation

@gumclaw

@gumclaw gumclaw commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

  • A 429 that names a Retry-After longer than 5s is reported at once instead of retried, and the error carries the wait.
  • A 429 with no Retry-After backs off 1s then 2s (was 200ms then 400ms) before giving up.
  • The 429 error names both request budgets and the one-request alternative: gumroad sales export.
  • skills/gumroad/SKILL.md: the --page-delay 200ms tip 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 at sales export for whole histories.

Why

A seller with ~60k sales read their whole history with --all and got their IP blocked with a Cloudflare 1015 mid-run: 6,836 GET /v2/sales requests, 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 the 429 made it worse in two ways: two retries inside 600ms, each one more request against an IP that is already blocked, and then Hint: Wait a moment and retry. An edge block lasts until the hourly window drains, so that hint is a loop.

Before/After

case before after
429, no Retry-After (what the edge sends on a 1015) 2 retries inside 600ms, then Hint: Wait a moment and retry. backs off 1s then 2s, then names both budgets and sales export
429 with Retry-After: 120 sleeps 120s, retries, sleeps 120s again reports immediately with the wait attached, no retry
200 — unchanged

Demo

demo

Demo shows a local mock edge answering every GET with a 429 and the Cloudflare 1015 page (no Retry-After), the old binary, the new binary, and the same command against a 200 from the same endpoint. It runs entirely against the mock, so nothing in it depends on the paired API change.

Depends on antiwork/gumroad#9202 only for the "100 sales per page" arithmetic quoted in skills/gumroad/SKILL.md; the 429 handling is independent and works against the API as deployed today.

Tests

  • internal/api/client_test.go: TestClient_GetStopsOnRateLimitThatNamesALongWait (1 attempt, RetryAfter 2m, the rate-limit hint) and TestClient_GetBacksOffInSecondsOnRateLimitWithoutAWait (3 attempts, sleeps 1s then 2s).
  • internal/api/errors_test.go: both 429 rows of TestAPIError_Hints assert the shared HintRateLimited.
  • go test ./internal/api/ -count=1 → ok ... 1.327s; go vet ./internal/... clean; gofmt -l internal/api empty.
  • go test ./... still fails TestUserJSON and TestUserJSONErrorWhenNotAuthenticated in ./test; both fail identically in a clean origin/main worktree (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

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.
@gumclaw gumclaw added the working Actively being built or verified by an agent label Nov 17, 2026
@gumclaw gumclaw self-assigned this Nov 17, 2026
@gumclaw
gumclaw marked this pull request as ready for review November 17, 2026 19:51
@gumclaw
gumclaw merged commit 9c21607 into main Nov 17, 2026
5 checks passed
@gumclaw
gumclaw deleted the gumclaw/gp4761-sales-429 branch November 17, 2026 19:51
@tastelint

tastelint Bot commented Nov 17, 2026

Copy link
Copy Markdown

Tastelint

The 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`):

![sales page size demo](https://i.ibb.co/Wp7DGZ2f/demo-api-page.gif)

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`):

![api docs page_key row](https://i.ibb.co/fYChVmjK/api-docs.png)

`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

working Actively being built or verified by an agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant