{"record":{"id":"e3470805cbf3a612","repo":"vercel/next.js","slug":"draft-mode-cannot-be-enabled-during-build-time-ins","errorCode":null,"errorMessage":"Draft mode cannot be enabled during build-time instant validation.","messagePattern":"Draft mode cannot be enabled during build-time instant validation\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/app-render/instant-validation/instant-samples.ts","lineNumber":238,"sourceCode":"      return Reflect.get(target, prop, receiver)\n    },\n  })\n}\n\n/**\n * Creates a DraftModeProvider that always returns isEnabled: false.\n */\nexport function createDraftModeForValidation(): DraftModeProvider {\n  // Create a minimal DraftModeProvider-compatible object\n  // that always reports draft mode as disabled.\n  //\n  // private properties that can't be set from outside the class.\n  return {\n    get isEnabled() {\n      return false\n    },\n    enable() {\n      throw new Error(\n        'Draft mode cannot be enabled during build-time instant validation.'\n      )\n    },\n    disable() {\n      throw new Error(\n        'Draft mode cannot be disabled during build-time instant validation.'\n      )\n    },\n  } as Partial<DraftModeProvider> as DraftModeProvider\n}\n\n/**\n * Creates params wrapped with an exhaustive proxy.\n * Accessing a param not declared in the sample will throw an error.\n */\nexport function createExhaustiveParamsProxy<TParams extends Params>(\n  underlyingParams: TParams,\n  declaredParamNames: Set<string>,","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/app-render/instant-validation/instant-samples.ts#L220-L256","documentation":"Scope guard on the stub DraftModeProvider used during build-time instant validation: sampling renders run at build time where enabling draft mode is meaningless (there is no request cookie to set), so the provider always reports isEnabled: false and throws on enable() to reject any sampled code path that tries to flip it.","triggerScenarios":"draftMode().enable() is called during build-time instant validation.","commonSituations":"Enabling draft mode inside code executed by the instant validation sampler at build time.","solutions":["Do not enable draft mode during build-time instant validation; guard the call with a build-time check."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}