{"record":{"id":"9e7caaad051ac477","repo":"oven-sh/bun","slug":"cannot-derive-nonnull-on-a-nonnull-type","errorCode":null,"errorMessage":"Cannot derive nonNull on a nonNull type","messagePattern":"Cannot derive nonNull on a nonNull type","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bindgen-lib-internal.ts","lineNumber":589,"sourceCode":"    }\n    this.assertDefaultIsValid(def);\n    return new TypeImpl(this.kind, this.data, {\n      ...this.flags,\n      default: def,\n    });\n  }\n\n  clamp(min?: number | bigint, max?: number | bigint) {\n    return this.#rangeModifier(min, max, \"clamp\");\n  }\n\n  enforceRange(min?: number | bigint, max?: number | bigint) {\n    return this.#rangeModifier(min, max, \"enforce\");\n  }\n\n  get nonNull() {\n    if (this.flags.nonNull) {\n      throw new Error(\"Cannot derive nonNull on a nonNull type\");\n    }\n    return new TypeImpl(this.kind, this.data, {\n      ...this.flags,\n      nonNull: true,\n    });\n  }\n\n  validateInt32(min?: number, max?: number) {\n    if (this.kind !== \"i32\") {\n      throw new Error(\"validateInt32 can only be used on i32 or u32\");\n    }\n    const rangeInfo = cAbiIntegerLimits(\"i32\");\n    return this.validateInteger(min ?? rangeInfo[0], max ?? rangeInfo[1]);\n  }\n\n  validateUint32(min?: number, max?: number) {\n    if (this.kind !== \"u32\") {\n      throw new Error(\"validateUint32 can only be used on i32 or u32\");","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bindgen-lib-internal.ts#L571-L607","documentation":"Codegen type-builder guard: the nonNull derivation was requested on a TypeImpl that already has flags.nonNull set. Applying nonNull twice is a no-op at best and usually indicates a duplicated modifier chain in schema code, so the builder throws instead of silently returning an identical type.","triggerScenarios":"Thrown at src/codegen/bindgen-lib-internal.ts:589 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the duplicate `.nonNull` in the type chain","Verify the parameter is meant to be non-null exactly once","Re-run codegen after cleanup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","contentChangedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}