From 870c6b50667682d81a1507b6cb78de3aad8ffef7 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Wed, 4 Mar 2026 14:15:16 -0800 Subject: [PATCH] fix(cli): read orgId from project entry in repo.json, not root The Vercel CLI's repo.json format puts orgId on each project entry, not at the root level. The CLI was reading repoConfig.orgId (undefined) instead of project.orgId, which meant teamId was never set. Without teamId, the world-vercel URL selector used the direct vercel-workflow.com URL instead of the api.vercel.com proxy, causing 401 errors because vercel-workflow.com only accepts OIDC tokens (not CLI auth tokens). Also fix the RepoProjectConfig/RepoProjectsConfig type definitions to match the actual repo.json structure. --- .changeset/fix-cli-team-id-repo-link.md | 5 +++++ packages/cli/src/lib/inspect/vercel-link.ts | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-cli-team-id-repo-link.md diff --git a/.changeset/fix-cli-team-id-repo-link.md b/.changeset/fix-cli-team-id-repo-link.md new file mode 100644 index 0000000000..efca1b04a5 --- /dev/null +++ b/.changeset/fix-cli-team-id-repo-link.md @@ -0,0 +1,5 @@ +--- +"@workflow/cli": patch +--- + +Fix CLI 401 errors by reading orgId from per-project entry in repo.json for newer Vercel CLI versions diff --git a/packages/cli/src/lib/inspect/vercel-link.ts b/packages/cli/src/lib/inspect/vercel-link.ts index 9226966b3f..61de998061 100644 --- a/packages/cli/src/lib/inspect/vercel-link.ts +++ b/packages/cli/src/lib/inspect/vercel-link.ts @@ -23,10 +23,13 @@ interface RepoProjectConfig { id: string; name: string; directory: string; + /** Per-project orgId — added in vercel/vercel#14967. Prefer this over root-level orgId. */ + orgId?: string; } interface RepoProjectsConfig { - orgId: string; + /** Legacy root-level orgId — older Vercel CLI versions put orgId here. */ + orgId?: string; remoteName: string; projects: RepoProjectConfig[]; } @@ -195,9 +198,16 @@ async function getProjectLinkFromRepoLink( logger.debug(`Found matching repo projects: ${JSON.stringify(projects)}`); if (projects.length === 1) { const project = projects[0]; + // Prefer per-project orgId (vercel/vercel#14967), fall back to + // root-level orgId for older Vercel CLI versions. + const orgId = project.orgId ?? repoLink.repoConfig?.orgId; + if (!orgId) { + logger.debug('No orgId found in repo link project or root config'); + return null; + } return { repoRoot: repoLink.rootPath, - orgId: repoLink.repoConfig.orgId, + orgId, projectId: project.id, projectName: project.name, projectRootDirectory: project.directory,