{"record":{"id":"6ff0d067d95f2fdb","repo":"influxdata/influxdb","slug":"invalid-magic-bytes-expected-expected-got-actual","errorCode":null,"errorMessage":"invalid magic bytes: expected {expected:?}, got {actual:?}","messagePattern":"invalid magic bytes: expected (.+?), got (.+?)","errorType":"error_code","errorClass":"FormatError","httpStatus":null,"severity":"critical","filePath":"influxdb3_catalog/src/format/mod.rs","lineNumber":171,"sourceCode":"    pub const fn none() -> Self {\n        Self(Self::NONE)\n    }\n\n    /// Create flags with UPGRADE_SAFE set.\n    pub const fn upgrade_safe() -> Self {\n        Self(Self::UPGRADE_SAFE)\n    }\n}\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","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_catalog/src/format/mod.rs#L153-L189","documentation":"`FormatError::InvalidMagic` is returned when the first 4 bytes of a catalog format file do not match the expected magic bytes. The library uses magic bytes to confirm a file is a valid catalog format file before parsing; mismatch means the file is not a catalog file or is corrupted.","triggerScenarios":"Opening/reading a catalog file whose header does not begin with the expected 4-byte magic; pointing the catalog at a wrong or empty file.","commonSituations":"Misconfigured object-store/file path pointing at the wrong file; truncated or zero-filled files after disk failure; files produced by a different tool or format.","solutions":["Verify the file path configuration points at the actual catalog file","Check whether the file is truncated/corrupted (compare size and first bytes) and restore from backup","Confirm the file was produced by the same influxdb3 catalog format, not another component"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let mut hdr = [0u8; 4];\nFile::open(&path)?.read_exact(&mut hdr)?;\nif hdr != EXPECTED_MAGIC {\n    return Err(format!(\"{path:?} is not a catalog file (magic {hdr:?})\"));\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(FormatError::InvalidMagic { expected, actual }) => {\n        log::error!(\"bad catalog file: expected {expected:?}, got {actual:?}\");\n        // fall back to backup\n    }\n    r => r?,\n}","preventionTips":["Verify configured catalog paths point at real catalog files","Checksum files after backup/restore operations","Guard against truncated or zero-filled files from failing disks"],"tags":["catalog","file-format","corruption","magic-bytes"],"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"}