{"record":{"id":"88172b269be71965","repo":"BoundaryML/baml","slug":"invalid-decimal-bigint-literal-len-bytes","errorCode":null,"errorMessage":"Invalid decimal bigint literal ({len} bytes)","messagePattern":"Invalid decimal bigint literal \\((.+?) bytes\\)","errorType":"error_code","errorClass":"CtypesError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_ctypes/src/error.rs","lineNumber":28,"sourceCode":"\n    #[error(\"Null buffer pointer\")]\n    NullBuffer,\n\n    #[error(\"Invalid handle key: {0}\")]\n    InvalidHandleKey(u64),\n\n    #[error(\"Map entry missing key\")]\n    MapEntryMissingKey,\n\n    /// Carries only the input length, not the input itself — untrusted hex\n    /// blobs can be up to the FFI decode cap (~67M chars), and embedding\n    /// them in error messages bloats logs and exposes payload contents.\n    #[error(\"Invalid bigint hex string ({len} bytes)\")]\n    InvalidBigint { len: usize },\n\n    /// Carries only the input length for over-cap decimal type literals, so a\n    /// hostile descriptor cannot amplify logs by echoing its full payload.\n    #[error(\"Invalid decimal bigint literal ({len} bytes)\")]\n    InvalidBigintLiteral { len: usize },\n\n    #[error(\n        \"Invalid InboundValue.value_type: a root union or optional does not identify one exact selected type\"\n    )]\n    InvalidInboundValueTypeRootUnion,\n\n    #[error(\"Union selected type `{selected}` is not a member of declared union `{union}`\")]\n    UnionSelectedTypeNotMember { selected: String, union: String },\n\n    #[error(\"Internal error: {0}\")]\n    InternalError(String),\n}\n","sourceCodeStart":10,"sourceCodeEnd":42,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_ctypes/src/error.rs#L10-L42","documentation":"CtypesError::InvalidBigintLiteral { len } is raised when a decimal type literal in a descriptor exceeds the accepted form/size. Like InvalidBigint, it carries only the byte length, so a hostile descriptor cannot amplify logs by echoing its full payload (per the source doc comment). It means the decimal literal string itself was not a valid/acceptable bigint literal.","triggerScenarios":"Supplying a type descriptor (e.g. for decimal/precision types) whose literal digits are malformed or over the cap — a decimal literal with invalid characters or an over-cap number of digits.","commonSituations":"Dynamically generated descriptors with user-supplied precision/scale values; copy-pasted descriptors with stray characters; fuzz or hostile descriptors pushing oversized literals across FFI.","solutions":["Keep decimal literals within the bridge's cap; reject oversized literals host-side before the call.","Validate the literal is pure decimal digits (optional sign) before sending.","Clamp precision/scale parameters to sane ranges when generating descriptors.","Treat repeated occurrences as hostile input and log only the length, as the library does."],"exampleFix":"// before\nliteral = digits.repeat(10_000_000)  # over cap -> InvalidBigintLiteral\nsend_descriptor(literal)\n// after\nif len(literal) > MAX_LITERAL_BYTES: raise ValueError(\"decimal literal too large\")\nsend_descriptor(literal)","handlingStrategy":"validation","validationCode":"MAX_LITERAL = 4096\ndef ensure_decimal_literal(lit: str):\n    body = lit[1:] if lit[:1] in \"+-\" else lit\n    if not body.isdigit() or len(lit) > MAX_LITERAL:\n        raise ValueError(\"decimal literal invalid or over cap\")","typeGuard":null,"tryCatchPattern":"try:\n    send_descriptor(literal)\nexcept BridgeError as e:\n    if \"Invalid decimal bigint literal\" in str(e):\n        raise ValueError(f\"reject decimal literal of length {len(literal)}\") from e\n    raise","preventionTips":["Clamp precision/scale when generating decimal descriptors","Validate literals are pure digits (optional sign) host-side","Never echo oversized hostile payloads into logs; log lengths instead"],"tags":["decimal","bigint","validation","ffi"],"backgroundTag":"invalid-argument-format","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}