fix: clear VERCEL_ORG_ID and VERCEL_PROJECT_ID env vars on alias retry - #312
Conversation
When retrying the alias command without --scope for personal accounts, the Vercel CLI was still reading VERCEL_ORG_ID and VERCEL_PROJECT_ID from the environment and using them as scope. Now both env vars are deleted before the retry, matching the intent of removing --scope.
|
Deploy preview for express-basic-auth ready! ✅ Preview Built with commit 1f123ea. |
|
Deploy preview for team-scope-test ready! ✅ Preview Built with commit 1f123ea. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the Vercel CLI would still consider Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
No issues found across 2 files
Requires human review: This PR modifies global environment variables and changes retry logic within a core deployment path, which requires human review to ensure no unintended side effects.
Architecture diagram
sequenceDiagram
participant Action as Deployment Script (index.js)
participant Env as Node process.env
participant CLI as Vercel CLI Binary
Note over Action,CLI: Initial Alias Attempt
Action->>CLI: exec: vercel alias [url] [domain] --scope [scope]
CLI->>Env: Read VERCEL_ORG_ID / VERCEL_PROJECT_ID
Env-->>CLI: Return env var values
CLI-->>Action: Exit Code 1 (Scope rejected)
Note over Action,CLI: Retry Logic (Triggered on Failure)
Action->>Env: NEW: delete process.env.VERCEL_ORG_ID
Action->>Env: NEW: delete process.env.VERCEL_PROJECT_ID
Action->>CLI: CHANGED: exec vercel alias [url] [domain] (no --scope flag)
CLI->>Env: Read env vars
Env-->>CLI: Null/Undefined
Note right of CLI: CLI now correctly defaults to<br/>Personal Account scope
CLI-->>Action: Exit Code 0 (Success)
There was a problem hiding this comment.
Code Review
This pull request modifies index.js to clear VERCEL_ORG_ID and VERCEL_PROJECT_ID from process.env when retrying an alias command after a scope rejection. The review highlights a potential race condition due to the direct modification of the global process.env in a parallel execution context, which could affect other concurrent operations. It suggests creating a local copy of the environment for the retry command to prevent unintended side effects and notes a similar issue in the vercelDeploy function.
There was a problem hiding this comment.
Pull request overview
This PR completes the personal-account alias retry fallback by ensuring the Vercel CLI can’t implicitly re-apply org/project scope via environment variables when retrying vercel alias without --scope.
Changes:
- Clear
process.env.VERCEL_ORG_IDandprocess.env.VERCEL_PROJECT_IDbefore retrying the alias command after detecting the personal-account scope error. - Rebuild
dist/index.jsto reflect the same behavior in the shipped bundle.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| index.js | Deletes VERCEL_ORG_ID / VERCEL_PROJECT_ID from the environment before alias retry to prevent implicit scope on personal accounts. |
| dist/index.js | Rebuilt distribution bundle containing the same env-var clearing on alias retry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use local env copy instead of mutating process.env in parallel callbacks - Add error.skipRetry to prevent useless outer retries for deterministic errors - Log alias command stdout/stderr to Actions output for debugging
|



Summary
--scopefor personal accounts, the Vercel CLI was still readingVERCEL_ORG_IDandVERCEL_PROJECT_IDfrom the environment and treating them as scope contextChanges
index.js: Deleteprocess.env.VERCEL_ORG_IDandprocess.env.VERCEL_PROJECT_IDbefore alias retrydist/index.js: Rebuilt bundle reflecting the same changeRoot Cause
The previous fix (#310) removed
--scopefrom the CLI arguments, but the Vercel CLI also readsVERCEL_ORG_IDfrom the environment as an implicit scope. Removing only the flag was insufficient; the env vars must also be cleared for the retry to operate without any scope context.Test Plan