Repository navigation
Description
Bug report
Describe the bug
On a preview branch associated with a git branch, every push triggers the platform's branch-action sync. When that sync redeploys an edge function, the new deployment starts without the project's custom edge-function secrets in its environment, even though supabase secrets list still shows them. The platform-managed SUPABASE_* secrets are present; only user-set secrets are missing.
Re-running supabase secrets set (without a deploy) does not fix it: the running function's environment is fixed at deploy time. Only a manual supabase functions deploy restores the secret.
This silently disables any security check that depends on a custom secret. Our case is a Custom Access Token auth hook that verifies GoTrue's webhook signature with a secret held as an edge-function secret. After a platform redeploy, verification quietly stops enforcing, because the function sees no secret and fails open. With fail-closed verification, every login on the branch would break instead.
To reproduce
- Create a preview branch associated with a git branch (
supabase branches create <name> --git-branch <branch>). - Set a custom secret on the branch:
supabase secrets set MY_SECRET=… --project-ref <branch-ref>. - Deploy an edge function that reads
Deno.env.get("MY_SECRET")and reports whether it is set. Observe it is set. - Push a commit to the git branch that changes that function's source.
- About 30–60 s later the
branch-actionworkflow runs and redeploys the function, which bumps its version. - Call the function again.
MY_SECRETis now unset, whilesupabase secrets liststill lists it.
Observed
| Function version | Deployed by | Custom secret visible to the function |
|---|---|---|
| v7 | manual deploy, secret already set | yes |
| v10 | manual deploy (secret set, then deploy) | yes |
| v11 | branch-action sync after a push |
no |
- Across 5 observed pushes, the sync ran 29–56 s after the push. It redeployed the function only when the function's source differed.
- At the second of the v11 redeploy, every platform
SUPABASE_*secret on the branch was re-written. The custom secret'supdated_atinsecrets listdid not change. supabase secrets setalone, followed by three probes, did not restore it.
Expected behavior
A platform-initiated redeploy should start the function with the same environment a user-initiated deploy gets, including custom secrets. Alternatively, the docs should state that branch syncs drop custom secrets.
Related (minor)
The current CLI accepts and silently ignores a secret name it rejects during supabase secrets set. It reports success and stores nothing, rather than returning an error.
System information
- Supabase CLI 2.113.0
- Hosted project with Branching enabled (GitHub integration), preview branch with a git-branch association
Activity