Skip to content
Latchkey

Supabase "functions deploy failed to bundle" in CI

Supabase Edge Functions run on Deno. supabase functions deploy bundles the function and uploads it to your project. It fails when the bundle has a bad import or syntax error, or when the CLI cannot authenticate to the project from CI.

What this error means

The deploy fails with "Failed to bundle function", "Access token not provided", or "Cannot find project ref". The function does not reach the project.

Supabase
Bundling Function: hello
Error: Access token not provided. Supply an access token by running
supabase login or setting the SUPABASE_ACCESS_TOKEN environment variable.

Common causes

No access token or project ref in CI

The CLI needs SUPABASE_ACCESS_TOKEN and a linked project ref. Interactive login does not carry over to a CI runner.

The function fails to bundle

A bad import, missing export, or syntax error in the function makes the Deno bundler fail before upload.

How to fix it

Provide the token and project ref

  1. Set SUPABASE_ACCESS_TOKEN from a CI secret.
  2. Pass the project ref to the deploy command.
  3. Run the deploy non-interactively.
.github/workflows/ci.yml
env:
  SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
run: supabase functions deploy hello --project-ref "$PROJECT_REF"

Fix the bundle locally first

Run the deploy or serve locally to surface the bundler error, then correct the import or syntax it reports.

Terminal
supabase functions serve hello

How to prevent it

  • Store the access token as a CI secret, never inline.
  • Pass --project-ref so the CLI knows the target without interactive linking.
  • Bundle functions locally before pushing to catch errors early.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →