Skip to content

fix: clear VERCEL_ORG_ID and VERCEL_PROJECT_ID env vars on alias retry - #312

Merged
amondnet merged 2 commits into
masterfrom
amondnet/vagabond-cyclamen
Mar 26, 2026
Merged

fix: clear VERCEL_ORG_ID and VERCEL_PROJECT_ID env vars on alias retry#312
amondnet merged 2 commits into
masterfrom
amondnet/vagabond-cyclamen

Conversation

@amondnet

Copy link
Copy Markdown
Owner

Summary

  • 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 treating them as scope context
  • Both env vars are now deleted before the retry, completing the fix started in fix: retry alias command without --scope for personal accounts #310

Changes

  • index.js: Delete process.env.VERCEL_ORG_ID and process.env.VERCEL_PROJECT_ID before alias retry
  • dist/index.js: Rebuilt bundle reflecting the same change

Root Cause

The previous fix (#310) removed --scope from the CLI arguments, but the Vercel CLI also reads VERCEL_ORG_ID from 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

  • Deploy to a personal Vercel account (no org) with alias domains configured
  • Verify the alias command succeeds on retry without scope-related errors
  • Verify org/project deployments are unaffected (env vars only cleared after first failure)

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.
Copilot AI review requested due to automatic review settings March 26, 2026 07:07
@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Deploy preview for express-basic-auth ready!

✅ Preview
https://express-basic-auth-1l7ni6lbn-minsu-lees-projects-b1e388b7.vercel.app

Built with commit 1f123ea.
This pull request is being automatically deployed with vercel-action

@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Deploy preview for team-scope-test ready!

✅ Preview
https://team-scope-test-2axh2lu42-dietfriends.vercel.app

Built with commit 1f123ea.
This pull request is being automatically deployed with vercel-action

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 VERCEL_ORG_ID and VERCEL_PROJECT_ID environment variables as scope context during an alias command retry, even when the --scope flag was removed. The solution involves proactively clearing these environment variables to ensure the retry operates without unintended scope implications, particularly for personal Vercel accounts.

Highlights

  • Environment Variable Clearing: The VERCEL_ORG_ID and VERCEL_PROJECT_ID environment variables are now explicitly deleted before retrying the Vercel alias command.
  • Alias Command Retry Fix: This change completes a previous fix, ensuring that the Vercel CLI does not implicitly use scope context from environment variables when retrying the alias command for personal accounts.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Loading

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread index.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ID and process.env.VERCEL_PROJECT_ID before retrying the alias command after detecting the personal-account scope error.
  • Rebuild dist/index.js to 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
@sonarqubecloud

Copy link
Copy Markdown

@amondnet
amondnet merged commit e34aeb6 into master Mar 26, 2026
9 of 14 checks passed
@amondnet
amondnet deleted the amondnet/vagabond-cyclamen branch March 26, 2026 08:03

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Requires human review: This change modifies core business logic related to CLI command retries and environment variable handling, which requires human review to ensure no unintended side effects.

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