{"record":{"id":"633e82b8662e9c70","repo":"vercel/next.js","slug":"the-next-deployment-id-environment-variable-value","errorCode":null,"errorMessage":"The NEXT_DEPLOYMENT_ID environment variable value \"${process.env.NEXT_DEPLOYMENT_ID}\" does not match the provided deploymentId \"${result.deploymentId}\" in the config.","messagePattern":"The NEXT_DEPLOYMENT_ID environment variable value \"(.+?)\" does not match the provided deploymentId \"(.+?)\" in the config\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":1141,"sourceCode":"\n  if (result?.turbopack?.chunkLoadingGlobal) {\n    const g = result.turbopack.chunkLoadingGlobal\n    if (!g.startsWith('TURBOPACK_')) {\n      result.turbopack.chunkLoadingGlobal = `TURBOPACK_${g}`\n    }\n  }\n\n  if (\n    result.experimental.runtimeServerDeploymentId == null &&\n    phase === PHASE_PRODUCTION_BUILD &&\n    ciEnvironment.hasNextSupport &&\n    process.env.NEXT_DEPLOYMENT_ID\n  ) {\n    if (\n      result.deploymentId != null &&\n      result.deploymentId !== process.env.NEXT_DEPLOYMENT_ID\n    ) {\n      throw new Error(\n        `The NEXT_DEPLOYMENT_ID environment variable value \"${process.env.NEXT_DEPLOYMENT_ID}\" does not match the provided deploymentId \"${result.deploymentId}\" in the config.`\n      )\n    }\n    result.experimental.runtimeServerDeploymentId = true\n  }\n\n  // only leverage deploymentId\n  if (process.env.NEXT_DEPLOYMENT_ID) {\n    result.deploymentId = process.env.NEXT_DEPLOYMENT_ID\n  }\n\n  if (process.env.NEXT_HASH_SALT) {\n    result.outputHashSalt =\n      (result.outputHashSalt ?? '') + (process.env.NEXT_HASH_SALT ?? '')\n  }\n\n  const tracingRoot = result?.outputFileTracingRoot\n  const turbopackRoot = result?.turbopack?.root","sourceCodeStart":1123,"sourceCodeEnd":1159,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L1123-L1159","documentation":"During a production build (`PHASE_PRODUCTION_BUILD`) on a CI platform with Next.js support, if `process.env.NEXT_DEPLOYMENT_ID` is set and the config also provides `deploymentId`, the two must match exactly (config.ts:1131-1144). The env var is the platform's source of truth for the deployment identity, and a mismatch would cause cache invalidation and asset path bugs.","triggerScenarios":"Hardcoding `deploymentId: 'abc123'` in next.config while deploying to a platform that sets `NEXT_DEPLOYMENT_ID=xyz789` (e.g. Vercel or a self-hosted platform emulating it). Only triggers when both values are present and differ during a production build with `ciEnvironment.hasNextSupport`.","commonSituations":"Copying a deploymentId from one environment into config used in another. Setting NEXT_DEPLOYMENT_ID in CI secrets while a stale deploymentId sits in the repo. Promoting a build artifact across deployment IDs.","solutions":["Remove the hardcoded `deploymentId` from next.config and let the platform drive it via NEXT_DEPLOYMENT_ID.","Or align the config value with the env var exactly.","Confirm ciEnvironment detection is intended; if you don't want platform-managed IDs, unset NEXT_DEPLOYMENT_ID in CI."],"exampleFix":"// before\nmodule.exports = { deploymentId: 'abc123' }  // env: NEXT_DEPLOYMENT_ID=xyz789\n// after\nmodule.exports = {}  // let NEXT_DEPLOYMENT_ID drive deploymentId","handlingStrategy":"validation","validationCode":"if (process.env.NEXT_DEPLOYMENT_ID && config.deploymentId && config.deploymentId !== process.env.NEXT_DEPLOYMENT_ID) {\n  throw new Error(`deploymentId ${config.deploymentId} != NEXT_DEPLOYMENT_ID ${process.env.NEXT_DEPLOYMENT_ID}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid hardcoding deploymentId in config; let the platform set NEXT_DEPLOYMENT_ID.","In CI, fail fast in a pre-build step if the two diverge."],"tags":["config","deployment","ci","environment-variables","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}