Skip to content

docs(capability-matrix): add specs for database and storage auto_retry - #190

Merged
grdsdev merged 2 commits into
mainfrom
guilherme/sdk-1791-auto-retry-specs
Dec 1, 2026
Merged

grdsdev merged 2 commits into
mainfrom
guilherme/sdk-1791-auto-retry-specs

Conversation

@grdsdev

@grdsdev grdsdev commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Adds spec files for two existing feature IDs that had none. Each spec has a decision flowchart.

  • database.configuration.auto_retry: a fixed rule. GET/HEAD only, 503/520 or a network failure, 4 attempts in total, a per-client switch and a per-request override in either direction. Full-jitter backoff (1 s base, 30 s cap). Retry-After is honoured up to 30 s; a longer value ends the retries. X-Retry-Count: n on the n-th retry. Cancellation, errors from caller-supplied hooks, and decoding errors are never retried.
  • storage.configuration.auto_retry: reads only (GET, HEAD, and the two list POSTs). Statuses 408, 429 (only with Retry-After), 500, 502–504, 520–524, 530. A per-client attempt count (default 3, 1 turns retries off). Full-jitter backoff (500 ms base, 20 s cap). Retries end when a streamed download returns.

How the SDKs compare today

JS Swift Flutter Python Kotlin Go C#
Database on by default yes yes yes yes yes yes no
methods GET/HEAD/OPTIONS GET/HEAD GET/HEAD GET/HEAD GET/HEAD GET/HEAD all
statuses 503, 520 503, 520 503, 520 wide set 503, 520 503, 520 408, 429, 5xx
attempts 4 4 4 4 4 4 1
jitter none full ±25 % partial none none full
Retry-After over cap waits in full clamps no retry no retry ignored waits in full ignored
Storage retry none reads, on uploads only, off GET/HEAD, on none no module metadata, off

The divergences from these specs become issues in each SDK repository after merge.

bun run validate passes. Written alongside supabase/supabase-swift#1341. Linear: SDK-1791.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Documentation
    • Added guidance on automatic retry behavior for database and storage requests, including which requests and failures are eligible for retries.
    • Documented retry limits, backoff timing, Retry-After handling, retry-count headers, and how cancellation and other errors affect retries.
    • Clarified that database retries can be configured per client or request, while storage retry limits are configured per client.

The pull request adds documentation for automatic retries in the database and Storage SDKs. The database specification describes retry rules for GET and HEAD requests. The Storage specification also covers two listing POST endpoints and documents additional 429 and Retry-After conditions. Both specifications describe attempt limits, retry-count headers, delays, and outcomes that are not retried.

Possibly related PRs

  • supabase/sdk#343: Adds an RPC specification that relies on the database retry contract documented here.

Change: Other

Merge Risk: Minimal · up to 02c55

This change adds documentation for automatic retry behavior in the database and storage SDKs. It does not change runtime behavior, and no merge-blocking issues were found.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f9bbe26-ccf4-4616-a866-df2bc6108cfa
Commits

Reviewing files that changed from the base of the PR and between d949e71 and 02c55dd.

Files selected for processing: 2

  • packages/capability-matrix/specs/database/configuration/auto_retry.md
  • packages/capability-matrix/specs/storage/configuration/auto_retry.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@spydon
spydon added this pull request to stack #344 November 9, 2026 12:36
@grdsdev
grdsdev force-pushed the guilherme/sdk-1791-auto-retry-specs branch from a10bf94 to c00ebb5 Compare November 26, 2026 09:34
@grdsdev
grdsdev marked this pull request as ready for review November 26, 2026 09:34
@grdsdev
grdsdev requested a review from a team as a code owner November 26, 2026 09:34

@spydon spydon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!
Merging this would also unblock #343

spydon added a commit to supabase/supabase-py that referenced this pull request Nov 30, 2026
Makes database and storage retries follow the `auto_retry` specs
([supabase/sdk#190](supabase/sdk#190)). Fixes
SDK-3240, closes #2143.

- **Database:** a forced `retry(True)` no longer sends a write twice.
Only GET and HEAD retry, on a network error, 503 or 520, with full
jitter. The client and `PostgrestClientOptions` take `retry: bool`.
- **Storage:** only reads retry, plus the `list()` POST. Adds 500, and a
429 retries only with `Retry-After`. The client and
`StorageClientOptions` take `max_attempts`. Uploads, including the POST
that creates a resumable upload, are never retried.
- **Auth and functions:** keep `RetryPolicy`, so the global `retry` of
the supabase client now applies to them only.
grdsdev and others added 2 commits December 1, 2026 08:52
PostgREST's rule is fixed (GET/HEAD, 503/520, 4 attempts, on/off switch
only); Storage's is configurable. Both share full-jitter capped backoff,
Retry-After honoured up to the cap, stop on cancellation, and no replay
of one-shot bodies or of errors thrown by caller-supplied code.

Refs SDK-1791, supabase/supabase-swift#1341.

Co-Authored-By: Claude <noreply@anthropic.com>
Rewrite both specs as normative contracts per the current TEMPLATE, after
comparing the retry code in all seven SDKs. Add a decision flowchart to each.

Database: state the per-request override works both ways, define what
counts as a transport failure, and stop retrying when Retry-After exceeds
the 30 s cap instead of clamping it.

Storage: restrict replays to reads (GET, HEAD and the two list POSTs),
drop the Idempotency-Key rule that the Storage API does not honour, retry
429 only with Retry-After, make the attempt count the only knob, and stop
retries once a streamed download returns.
@spydon
spydon force-pushed the guilherme/sdk-1791-auto-retry-specs branch from c00ebb5 to 02c55dd Compare December 1, 2026 07:52
@grdsdev
grdsdev merged commit 8f4bde7 into main Dec 1, 2026
7 checks passed
@grdsdev
grdsdev deleted the guilherme/sdk-1791-auto-retry-specs branch December 1, 2026 07:55
grdsdev pushed a commit that referenced this pull request Dec 1, 2026
…est method (#343)

Stacked on #190, which adds the `database.configuration.auto_retry` spec
this file links to. Retarget to `main` once #190 merges.

Adds `specs/database/query/rpc.md`, which defines which HTTP method a
function call uses:

- A call is a `POST` unless the caller asks for a read-only call on that
call. The SDK never picks `GET` on its own: not from the volatility of
the function, not from the shape of the arguments, and not to make the
call retryable. Generated function calls
(`database.generated_types.typed_rpc`) follow the same rule.
- The reasons, each stated as the premise of that rule: PostgREST runs
every `GET` read-only, so a `VOLATILE` function that writes fails over
`GET` with HTTP 405 `25006`; the Supabase API load balancer sends `GET`
to read replicas, so a read right after a write can miss it; and `GET`
arguments are part of the URL, which logs record.
- A read-only call is sent as `GET` and retried under `auto_retry`. It
falls back to `POST`, without retry, when an argument cannot reach the
function as a query parameter: a name PostgREST reads as a request
option or embed path, a `null`, or a value that starts like a filter
(`eq.foo`). Argument values are runtime data, so this changes the method
instead of failing the call.
- A read-only call whose arguments are not a JSON object of named
arguments, such as the whole body of a single unnamed `json` parameter,
is rejected before the wire.

Checked against the PostgREST docs
([functions](https://docs.postgrest.org/en/latest/references/api/functions.html),
[access
mode](https://docs.postgrest.org/en/latest/references/transactions.html#access-mode-on-functions))
and the [read replicas
guide](https://supabase.com/docs/guides/platform/read-replicas). The
filter rule was checked against a local stack: `GET
/rpc/get_username_and_status?name_param=eq.supabot` answers HTTP 404
`PGRST202`, because PostgREST reads the parameter as a filter and looks
for the function without that argument.

This came out of supabase/supabase-flutter#2146 (SDK-2914), where
generated calls of `STABLE` functions had been switched to `GET` by the
generator. Once this merges, divergences get issues in the SDK
repositories that cite this file.

`bun run validate` passes (`OK — capability matrix is valid.`), and `bun
run test` passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants