{"record":{"id":"1eb529e862c72523","repo":"oven-sh/bun","slug":"validateint32-can-only-be-used-on-i32-or-u32","errorCode":null,"errorMessage":"validateInt32 can only be used on i32 or u32","messagePattern":"validateInt32 can only be used on i32 or u32","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bindgen-lib-internal.ts","lineNumber":599,"sourceCode":"  }\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\");\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;","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bindgen-lib-internal.ts#L581-L617","documentation":"Bindgen DSL guard: `.validateInt32(...)` was called on a type whose kind is not i32 (the message mentions i32 or u32; the implementation currently only accepts i32). Integer range validation is only defined for 32-bit integer ABI types, so the misuse throws at codegen time.","triggerScenarios":"Thrown at src/codegen/bindgen-lib-internal.ts:599 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the argument kind to i32/u32 as appropriate","Use the matching validator for the actual kind (e.g. f64 -> finite/clamp)","Re-run codegen after aligning kind and validator"],"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"}