Skip to content

feat(cli): add SUPABASE_API_MAX_RETRIES to cap api retries (CLI-2607) - #7394

Open
7ttp wants to merge 7 commits into
developfrom
7ttp/cli-2607-expose-an-explicit-zero-retry-option-for-the-official
Open

7ttp wants to merge 7 commits into
developfrom
7ttp/cli-2607-expose-an-explicit-zero-retry-option-for-the-official

Conversation

@7ttp

@7ttp 7ttp commented Oct 29, 2026

Copy link
Copy Markdown
Member

TL;DR

adds SUPABASE_API_MAX_RETRIES so automation can cap management api retries, where 0 sends each request once.

whats introduced?

the new env var sets the retry count on every management api client the cli builds
login and services included.
functions deploy drops its own retry loops when it is set and only keeps turning a duplicated create into an update. an invalid value stops the command before any request, and leaving it unset keeps today's behavior...

flowchart TD
  env["SUPABASE_API_MAX_RETRIES"] --> parse{"CommandSettings.load"}
  parse -- "unset or empty" --> none["none: today's behaviour"]
  parse -- "plain digits, e.g. 0 or 2" --> some["some(n)"]
  parse -- "anything else" --> err["ApiMaxRetriesError, exit 1, 0 requests"]

  none --> defaults["client retries 5 times, deploy keeps its own loops"]

  some --> clients["Management API clients: retry.maxRetries = n"]
  clients --> platform["platform api: projects, secrets, link, ..."]
  clients --> login["login profile lookup"]
  clients --> services["services version lookup"]

  some --> deploy["functions deploy: DeployApiMaxRetries"]
  deploy --> single["command loops off, the client is the only retry layer"]
  single --> dup["duplicated create still becomes one update"]
Loading

why?

the management api client retries retryable failures up to 5 times with no way to change that,
so eg: a failing projects list sends 6 requests, automation that has to stop on the first failure had no supported way to send each request once....

ref

@7ttp 7ttp self-assigned this Oct 29, 2026
@7ttp
7ttp requested a review from a team as a code owner October 29, 2026 13:49

@github-actions github-actions Bot 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.

Superseded by a newer AI review

🤖 AI Review

Both independent reviews were available. All four findings are confirmed, with no duplicates. Setting a positive retry limit removes bundled-deploy retries for transient POST/PATCH failures; malformed values also block local commands; configured deploy retries silently reject Retry-After delays over 10 seconds; and the new test waits through real backoff. The rate-limit finding is raised to minor because it can terminate deployment. Verification was by code inspection; dependencies were unavailable for test execution.

Findings

Severity Location Category Sources Claim
🟡 MINOR apps/cli/src/shared/functions/deploy.ts:2035 correctness claude A positive SUPABASE_API_MAX_RETRIES disables the bundled deployment's existing retries for POST/PATCH 5xx and transport failures without providing equivalent client retries. Setting it to 5 can therefore make a transient failure terminate deployment on the first attempt.
🟡 MINOR apps/cli/src/config/command-settings.layer.ts:203 error-handling claude Malformed SUPABASE_API_MAX_RETRIES values fail shared settings construction even for commands that do not use the Management API, including local database dumps.
🟡 MINOR apps/cli/src/shared/functions/deploy.ts:1789 ux claude Configuring a positive retry limit removes deploy's rate-limit notices and changes long Retry-After handling: a 429 requesting more than 10 seconds now terminates upload or bulk update instead of waiting.
🟡 MINOR apps/cli/src/commands/functions/deploy/deploy.integration.test.ts:2352 test-quality codex The new duplicate-function test waits through production retry backoff in real time although it only verifies the POST-to-PATCH transition and request count.

Stats

Claude findings: 3 · Codex findings: 1 · Confirmed: 4 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread apps/cli/src/shared/functions/deploy.ts
Comment thread apps/cli/src/config/command-settings.layer.ts
Comment thread apps/cli/src/shared/functions/deploy.ts
Comment thread apps/cli/src/commands/functions/deploy/deploy.integration.test.ts Outdated
@7ttp
7ttp marked this pull request as draft October 29, 2026 14:07
@7ttp
7ttp marked this pull request as ready for review October 29, 2026 14:32
@github-actions

Copy link
Copy Markdown
Contributor

CLI benchmark: no changes found

Commit 954bd72 against develop at 3a9e1fb · 10 runs each · report only, never blocks merging

Command Before After Change
supabase --version 203 ms 203 ms no real change
supabase --help 202 ms 203 ms no real change
supabase init 221 ms 216 ms no real change
supabase migration new bench 280 ms 259 ms no real change (-8%, within normal variation)
supabase gen types --lang typescript --project-id replayfixtureprojref 404 ms 325 ms no real change (-19%, within normal variation)
supabase projects list 261 ms 270 ms no real change
supabase functions list --project-ref replayfixtureprojref 271 ms 261 ms no real change

API calls: unchanged for all 7 commands.

Binary size: 133.8 MB, up 4.0 KB from 133.8 MB.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Before range After range Change Verdict
supabase --version 184-233 ms 193-314 ms 0 ms (0%) within noise
supabase --help 175-252 ms 186-231 ms +1 ms (+1%) within noise
supabase init 196-262 ms 179-284 ms -4 ms (-2%) within noise
supabase migration new bench 236-352 ms 211-565 ms -22 ms (-8%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref 263-467 ms 262-518 ms -79 ms (-19%) within noise
supabase projects list 230-503 ms 232-314 ms +9 ms (+4%) within noise
supabase functions list --project-ref replayfixtureprojref 236-328 ms 224-313 ms -9 ms (-3%) within noise

API calls per command

Command Before After Endpoint changes
supabase --version 0 0
supabase --help 0 0
supabase init 0 0
supabase migration new bench 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref 2 2
supabase projects list 1 1
supabase functions list --project-ref replayfixtureprojref 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Comment /bench to run it again on the latest commit.

Workflow run

@7ttp

7ttp commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

/ai-review

@github-actions github-actions Bot 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.

🤖 AI Review

Confirmed three minor concerns from Claude: the template overstates retry suppression, command environment-variable contracts omit the new setting, and eager validation also affects offline commands. Codex's independent review completed with no findings. No major or critical issues were verified. Tests were not run.

Findings

Severity Location Category Sources Claim
🟡 MINOR apps/cli/src/SIDE_EFFECTS_TEMPLATE.md:65 documentation claude The template's 0 = one attempt wording does not account for command-level retries. With SUPABASE_API_MAX_RETRIES=0, bootstrap can still issue nine failing API-key requests.
🟡 MINOR apps/cli/src/commands/functions/deploy/SIDE_EFFECTS.md:64 documentation claude Only functions deploy's command contract documents SUPABASE_API_MAX_RETRIES, although the new setting affects other commands, including login and services.
🟡 MINOR apps/cli/src/config/command-settings.layer.ts:204 error-handling claude An invalid SUPABASE_API_MAX_RETRIES prevents offline commands from starting because validation runs during settings-layer construction, even when no Management API request is needed. This broader failure scope is undocumented.

Stats

Claude findings: 3 · Codex findings: 0 · Confirmed: 3 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: manual · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread apps/cli/src/SIDE_EFFECTS_TEMPLATE.md Outdated
Comment thread apps/cli/src/commands/functions/deploy/SIDE_EFFECTS.md
Comment thread apps/cli/src/config/command-settings.layer.ts

This branch has not been deployed

No deployments
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.

Expose an explicit zero-retry option for the official Supabase CLI

1 participant