{"record":{"id":"c1676227d8ef7f8e","repo":"vercel/next.js","slug":"draft-mode-cannot-be-disabled-during-build-time-in","errorCode":null,"errorMessage":"Draft mode cannot be disabled during build-time instant validation.","messagePattern":"Draft mode cannot be disabled 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":243,"sourceCode":"/**\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>,\n  route: string\n): TParams {\n  return new Proxy(underlyingParams, {\n    get(target, prop, receiver) {\n      if (","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/app-render/instant-validation/instant-samples.ts#L225-L261","documentation":"Scope guard on the validation-time DraftModeProvider: disable() was called during build-time instant validation. As with enable(), draft mode state cannot be mutated in a sampling render, so the stub rejects the mutation while still reporting isEnabled: false.","triggerScenarios":"draftMode().disable() is called during build-time instant validation.","commonSituations":"Disabling draft mode inside code executed by the instant validation sampler at build time.","solutions":["Do not disable 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"}