{"record":{"id":"23e477fcc50db06d","repo":"vercel/next.js","slug":"failed-to-link-project-linkres-stdout-linkres","errorCode":null,"errorMessage":"Failed to link project ${linkRes.stdout} ${linkRes.stderr} (${linkRes.exitCode})","messagePattern":"Failed to link project (.+?) (.+?) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bench/vercel/project-utils.js","lineNumber":143,"sourceCode":"}\n\nexport async function deployProject(projectName, appFolder) {\n  try {\n    const vercelFlags = ['--scope', TEST_TEAM_NAME]\n    const vercelEnv = { ...process.env, TOKEN: TEST_TOKEN }\n\n    // link the project\n    const linkRes = await execa(\n      'vercel',\n      ['link', '-p', projectName, '--confirm', ...vercelFlags],\n      {\n        cwd: appFolder,\n        env: vercelEnv,\n      }\n    )\n\n    if (linkRes.exitCode !== 0) {\n      throw new Error(\n        `Failed to link project ${linkRes.stdout} ${linkRes.stderr} (${linkRes.exitCode})`\n      )\n    }\n\n    const deployRes = await execa(\n      'vercel',\n      [\n        'deploy',\n        '--build-env',\n        'NEXT_PRIVATE_TEST_MODE=1',\n        '--build-env',\n        'NEXT_TELEMETRY_DISABLED=1',\n        ...(VERCEL_EDGE_FUNCTIONS_BRIDGE_PKG\n          ? [\n              '--build-env',\n              `VERCEL_EDGE_FUNCTIONS_BRIDGE_PKG=${VERCEL_EDGE_FUNCTIONS_BRIDGE_PKG}`,\n            ]\n          : []),","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/bench/vercel/project-utils.js#L125-L161","documentation":"Thrown by deployProject in the Vercel benchmark harness when `vercel link -p <project> --confirm` exits with a non-zero code. The link step associates the local app folder with an existing Vercel project under the test team scope; failure here blocks deployment. The message includes the command's stdout, stderr, and exit code.","triggerScenarios":"The project name does not exist in the team; the TEST_TOKEN is invalid/expired; the TEST_TEAM_NAME scope is wrong or the token lacks access; network/CLI error; vercel CLI not installed or wrong version; the local folder is already linked to a different project.","commonSituations":"Expired test token in CI secrets; the benchmark project was deleted from the team; scope mismatch; vercel CLI version drift changes link flags.","solutions":["Read the included stderr — it usually states auth failure, project not found, or scope error.","Verify TEST_TOKEN is valid and not expired; rotate it if needed.","Confirm TEST_TEAM_NAME matches a team the token can access and that the project exists there.","Ensure the vercel CLI is installed and the folder is not already linked (run `vercel unlink` or remove the .vercel/ folder)."],"exampleFix":"# before: stale token\nTOKEN=expired ...\n\n# after: rotate token in Vercel dashboard, set fresh secret\nvercel whoami --token $TEST_TOKEN  # confirm works","handlingStrategy":"validation","validationCode":"// Verify auth + project existence before linking\nimport execa from 'execa'\nasync function preflight(token: string, scope: string, project: string) {\n  const who = await execa('vercel', ['whoami', '--token', token])\n  if (who.exitCode !== 0) throw new Error('TEST_TOKEN invalid or expired')\n  const ls = await execa('vercel', ['ls', '--scope', scope, '--token', token])\n  if (!ls.stdout.includes(project)) throw new Error(`Project ${project} not found in ${scope}`)\n}","typeGuard":"null","tryCatchPattern":"try {\n  await deployProject(name, folder)\n} catch (e) {\n  // message includes stdout/stderr/exitCode from vercel link\n  console.error('Link failed — check token/scope/project:', (e as Error).message)\n  throw e\n}","preventionTips":["Rotate TEST_TOKEN before it expires and store it as a fresh CI secret.","Confirm the project exists in TEST_TEAM_NAME before running.","Run `vercel unlink` or remove .vercel/ if the folder was previously linked."],"tags":["vercel","deployment","cli","auth"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}