-
Notifications
You must be signed in to change notification settings - Fork 245
Fix projectConfig.projectId containing project name instead of ID #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@workflow/cli": patch | ||
| "@workflow/core": patch | ||
| "@workflow/web": patch | ||
| "@workflow/world-vercel": patch | ||
| --- | ||
|
|
||
| Separate project ID and project name into distinct env vars (WORKFLOW_VERCEL_PROJECT and WORKFLOW_VERCEL_PROJECT_NAME) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ export const getEnvVars = (): Record<string, string> => { | |
| WORKFLOW_VERCEL_ENV: env.WORKFLOW_VERCEL_ENV || '', | ||
| WORKFLOW_VERCEL_AUTH_TOKEN: env.WORKFLOW_VERCEL_AUTH_TOKEN || '', | ||
| WORKFLOW_VERCEL_PROJECT: env.WORKFLOW_VERCEL_PROJECT || '', | ||
| WORKFLOW_VERCEL_PROJECT_NAME: env.WORKFLOW_VERCEL_PROJECT_NAME || '', | ||
| WORKFLOW_VERCEL_TEAM: env.WORKFLOW_VERCEL_TEAM || '', | ||
| WORKFLOW_LOCAL_UI: env.WORKFLOW_LOCAL_UI || '', | ||
| PORT: env.PORT || '', | ||
|
|
@@ -184,13 +185,27 @@ export const inferVercelProjectAndTeam = async () => { | |
| export const inferVercelEnvVars = async () => { | ||
| const envVars = getEnvVars(); | ||
|
|
||
| if (!envVars.WORKFLOW_VERCEL_PROJECT || !envVars.WORKFLOW_VERCEL_TEAM) { | ||
| // Infer project/team from .vercel folder when: | ||
| // - WORKFLOW_VERCEL_PROJECT or WORKFLOW_VERCEL_TEAM is missing, OR | ||
| // - WORKFLOW_VERCEL_PROJECT is set but doesn't look like a real project ID | ||
| // (e.g., user passed a slug via --project flag), OR | ||
| // - WORKFLOW_VERCEL_PROJECT_NAME is missing (need to populate the slug) | ||
| const needsInference = | ||
| !envVars.WORKFLOW_VERCEL_PROJECT || | ||
| !envVars.WORKFLOW_VERCEL_TEAM || | ||
| !envVars.WORKFLOW_VERCEL_PROJECT_NAME || | ||
| !envVars.WORKFLOW_VERCEL_PROJECT.startsWith('prj_'); | ||
|
|
||
| if (needsInference) { | ||
| logger.debug('Inferring vercel project and team from .vercel folder'); | ||
| const inferredProject = await inferVercelProjectAndTeam(); | ||
| if (inferredProject) { | ||
| const { projectId, projectName, teamId } = inferredProject; | ||
| envVars.WORKFLOW_VERCEL_PROJECT = projectName || projectId; | ||
| envVars.WORKFLOW_VERCEL_TEAM = teamId; | ||
| // WORKFLOW_VERCEL_PROJECT is the real project ID (e.g., prj_xxx) | ||
| envVars.WORKFLOW_VERCEL_PROJECT = projectId; | ||
| // WORKFLOW_VERCEL_PROJECT_NAME is the project slug (e.g., my-app) | ||
| envVars.WORKFLOW_VERCEL_PROJECT_NAME = projectName || projectId; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This guard on line 188 ( Consider also running normalization when
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Expanded the guard to also run inference when:
Also changed the team assignment to preserve an explicitly set team ( |
||
| envVars.WORKFLOW_VERCEL_TEAM = envVars.WORKFLOW_VERCEL_TEAM || teamId; | ||
| writeEnvVars(envVars); | ||
| } else { | ||
| logger.warn( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inferVercelEnvVars()only populatesWORKFLOW_VERCEL_PROJECT_NAME(and normalizesWORKFLOW_VERCEL_PROJECTto a realprj_…id) when eitherWORKFLOW_VERCEL_PROJECTorWORKFLOW_VERCEL_TEAMis missing. If the CLI flag/env already setsWORKFLOW_VERCEL_PROJECTto a project slug/name (which the--projectflag description currently implies), this block won’t run, and the world will continue sending the slug in thex-vercel-project-idheader—reintroducing the exact bug this PR is fixing and potentially breaking auth/encryption context. Consider expanding the guard to also run whenWORKFLOW_VERCEL_PROJECT_NAMEis missing and/or whenWORKFLOW_VERCEL_PROJECTdoesn’t look like a Vercel project id (e.g. notprj_…), so the env vars are consistently normalized.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inference logic normalizes the env var to a real project ID when the linked project is available. If the user sets
WORKFLOW_VERCEL_PROJECTto a slug, the inference step replaces it with the real ID from.vercel/project.json.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed — the guard now also runs when
WORKFLOW_VERCEL_PROJECTdoes not start withprj_or whenWORKFLOW_VERCEL_PROJECT_NAMEis missing, ensuring consistent normalization regardless of how the env vars were initially populated.