{"record":{"id":"ef38584edf35f855","repo":"oven-sh/bun","slug":"validateuint32-can-only-be-used-on-i32-or-u32","errorCode":null,"errorMessage":"validateUint32 can only be used on i32 or u32","messagePattern":"validateUint32 can only be used on i32 or u32","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bindgen-lib-internal.ts","lineNumber":607,"sourceCode":"      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\");\n    }\n    const rangeInfo = cAbiIntegerLimits(\"u32\");\n    return this.validateInteger(min ?? rangeInfo[0], max ?? rangeInfo[1]);\n  }\n\n  validateInteger(min?: number | bigint, max?: number | bigint) {\n    min ??= Number.MIN_SAFE_INTEGER;\n    max ??= Number.MAX_SAFE_INTEGER;\n    const enforceRange = this.#rangeModifier(min, max, \"enforce\") as TypeImpl;\n    enforceRange.flags.nodeValidator = NodeValidator.validateInteger;\n    return enforceRange;\n  }\n}\n\nexport function cAbiIntegerLimits(type: CAbiType) {\n  switch (type) {\n    case \"u8\":\n      return [0, 255];","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bindgen-lib-internal.ts#L589-L625","documentation":"Type-builder guard in the bindgen library: validateUint32() was called on a type whose kind isn't \"u32\" (and, for its sibling, validateInt32 on non-\"i32\"). Range validation only applies to matching integer kinds.","triggerScenarios":"Thrown at src/codegen/bindgen-lib-internal.ts:607 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the argument kind to u32","Use validateInt32 for signed i32 or other validators per kind","Re-run codegen after fixing the type"],"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"}