{"record":{"id":"303b902c302b6e80","repo":"influxdata/influxdb","slug":"buffer-too-short-expected-at-least-expected-bytes-got-actual","errorCode":null,"errorMessage":"buffer too short: expected at least {expected} bytes, got {actual}","messagePattern":"buffer too short: expected at least (.+?) bytes, got (.+?)","errorType":"error_code","errorClass":"FormatError","httpStatus":null,"severity":"critical","filePath":"influxdb3_catalog/src/format/mod.rs","lineNumber":179,"sourceCode":"}\n\n/// Errors that can occur when working with the binary format.\n#[derive(Debug, Clone, thiserror::Error)]\npub enum FormatError {\n    /// A decoded record failed to apply to the catalog.\n    #[error(transparent)]\n    Apply(#[from] apply::ApplyError),\n\n    /// Invalid magic bytes at start of file.\n    #[error(\"invalid magic bytes: expected {expected:?}, got {actual:?}\")]\n    InvalidMagic { expected: [u8; 4], actual: [u8; 4] },\n\n    /// Unsupported format version.\n    #[error(\"unsupported format version: {version}\")]\n    UnsupportedVersion { version: u32 },\n\n    /// Buffer too short for required data.\n    #[error(\"buffer too short: expected at least {expected} bytes, got {actual}\")]\n    BufferTooShort { expected: usize, actual: usize },\n\n    /// Header CRC32 checksum mismatch.\n    #[error(\"header CRC32 mismatch: expected {expected:#010x}, actual {actual:#010x}\")]\n    HeaderCrc32Mismatch { expected: u32, actual: u32 },\n\n    /// Payload CRC32 checksum mismatch.\n    #[error(\"payload CRC32 mismatch: expected {expected:#010x}, computed {computed:#010x}\")]\n    Crc32Mismatch { expected: u32, computed: u32 },\n\n    /// Unknown record type without UPGRADE_SAFE flag — hard error.\n    #[error(\"unknown record id {record_id} without UPGRADE_SAFE flag\")]\n    UnknownNonUpgradeSafeRecord { record_id: u16 },\n\n    /// Invalid record length.\n    #[error(\"invalid record length: {length}\")]\n    InvalidRecordLength { length: u32 },\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_catalog/src/format/mod.rs#L161-L197","documentation":"`FormatError::BufferTooShort` is returned when a buffer read from a catalog format file is shorter than the minimum bytes required for the expected structure (header, record, etc.). It indicates a truncated or malformed file/stream rather than a caller mistake.","triggerScenarios":"Decoding a catalog file or record whose byte buffer has fewer bytes than the parser requires (expected/actual counts in the error).","commonSituations":"Truncated catalog files after a crash, interrupted write, or failed sync; partial file copies during backup/restore; network/object-store reads returning incomplete data.","solutions":["Restore the catalog file from a complete backup","Check storage integrity — re-copy or re-download the file and compare checksums/sizes","Investigate the writer/crash that truncated the file; ensure durable writes (fsync) are functioning"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let meta = fs::metadata(&path)?;\nif meta.len() < MIN_CATALOG_SIZE {\n    return Err(format!(\"catalog file {path:?} looks truncated ({} bytes)\", meta.len()));\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(FormatError::BufferTooShort { expected, actual }) => {\n        log::error!(\"truncated catalog buffer: need {expected}, got {actual}\");\n        // restore from backup\n    }\n    r => r?,\n}","preventionTips":["Ensure durable writes (fsync) and clean shutdowns","Verify file sizes/checksums after backup copies","Avoid copying catalog files while the server is running"],"tags":["catalog","truncation","file-format","corruption"],"backgroundTag":"checksum-mismatch","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}