Skip to content

fix(functions): forward NPM_AUTH_TOKEN to deploy bundler container#4933

Open
addniner wants to merge 1 commit into
supabase:developfrom
addniner:fix/deploy-env-file
Open

fix(functions): forward NPM_AUTH_TOKEN to deploy bundler container#4933
addniner wants to merge 1 commit into
supabase:developfrom
addniner:fix/deploy-env-file

Conversation

@addniner

@addniner addniner commented Mar 5, 2026

Copy link
Copy Markdown

Summary

The Docker bundler for functions deploy forwards NPM_CONFIG_REGISTRY from the host environment into the container. When .npmrc uses ${NPM_AUTH_TOKEN} for private registry authentication, the token also needs to be available inside that bundler container.

This PR forwards NPM_AUTH_TOKEN from the host environment alongside NPM_CONFIG_REGISTRY.

Addresses the CI/CD host environment case in #4927.

Reproduction

# Method Result Error
1 supabase functions deploy hello (.npmrc with ${NPM_AUTH_TOKEN}) Fail 401 unauthenticated
2 NPM_AUTH_TOKEN=xxx supabase functions deploy hello Fail 401 unauthenticated (env not forwarded to container)
3 .npmrc with hardcoded token Pass -
4 NPM_AUTH_TOKEN=xxx with patched CLI Pass -

Tested with a private package (@addniner/test-private-pkg) on GitHub Packages, with Docker cache cleared between attempts.

Testing

  • go test ./internal/functions/deploy

@addniner addniner requested a review from a team as a code owner March 5, 2026 13:32
@coderabbitai

coderabbitai Bot commented Mar 5, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 3093be78-76e4-4c3c-a44e-32ffb08d7c87

📥 Commits

Reviewing files that changed from the base of the PR and between 9efbdaa and 7e87154.

📒 Files selected for processing (1)
  • internal/functions/deploy/bundle.go

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Updated bundling process to pass authentication environment variables to Docker when available, improving flexibility of the deployment environment configuration.

Walkthrough

The pull request modifies the bundle deployment logic to read the NPM_AUTH_TOKEN environment variable and inject it into the Docker environment during function bundling. This enables the Docker container to access the token when resolving dependencies from private npm registries during deployment, addressing the failure that occurs when using .npmrc files with environment variable placeholders.

Assessment against linked issues

Objective Addressed Explanation
Enable functions deploy to resolve ${NPM_AUTH_TOKEN} in .npmrc for private npm registry authentication [#4927]

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23181606618

Details

  • 1 of 3 (33.33%) changed or added relevant lines in 1 file are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 61.851%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/functions/deploy/bundle.go 1 3 33.33%
Files with Coverage Reduction New Missed Lines %
internal/utils/git.go 5 57.14%
Totals Coverage Status
Change from base Build 23149550253: -0.03%
Covered Lines: 7878
Relevant Lines: 12737

💛 - Coveralls

@addniner addniner force-pushed the fix/deploy-env-file branch from b1d64e9 to 570e41a Compare June 9, 2026 00:10
@addniner

addniner commented Jun 9, 2026

Copy link
Copy Markdown
Author

Updated this PR against the current develop branch and resolved the stale path/conflict state.

I kept the scope to host environment forwarding for Docker-based deploys, matching the existing NPM_CONFIG_REGISTRY behavior. Also added focused test coverage for the npm env forwarding helper.

Tested with:

go test ./internal/functions/deploy

The Docker bundler for functions deploy forwards NPM_CONFIG_REGISTRY
from the host environment into the container. When .npmrc uses
${NPM_AUTH_TOKEN} for private registry authentication, the token must
be available in that same bundler container for npm package resolution.

Forward NPM_AUTH_TOKEN alongside NPM_CONFIG_REGISTRY and cover both npm
env entries with a focused unit test.

Addresses supabase#4927
@addniner addniner force-pushed the fix/deploy-env-file branch from 570e41a to 74922d7 Compare June 9, 2026 00:11
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