{"record":{"id":"53be60186e2d2fd9","repo":"influxdata/influxdb","slug":"json-serialization-deserialization-failed-table-index-cache","errorCode":null,"errorMessage":"JSON serialization/deserialization failed","messagePattern":"JSON serialization/deserialization failed","errorType":"exception","errorClass":"TableIndexCacheError","httpStatus":null,"severity":"error","filePath":"influxdb3_write/src/table_index_cache.rs","lineNumber":45,"sourceCode":"use influxdb3_wal::SnapshotSequenceNumber;\n\nuse crate::{\n    ParquetFile,\n    paths::{\n        SnapshotInfoFilePath, TableIndexConversionCompletedPath, TableIndexPath,\n        TableIndexSnapshotPath,\n    },\n    table_index::{CoreTableIndex, IndexMetadata, TableIndex, TableIndexSnapshot},\n};\n\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum TableIndexCacheError {\n    #[error(\"Object store operation failed\")]\n    ObjectStore(#[source] object_store::Error),\n\n    #[error(\"JSON serialization/deserialization failed\")]\n    Json(#[source] serde_json::Error),\n\n    #[error(\"TableIndex operation failed\")]\n    TableIndex(#[source] crate::table_index::TableIndexError),\n\n    #[error(\"Object meta is missing filename\")]\n    MissingFilename,\n\n    #[error(\"Failed to parse snapshot sequence number from filename\")]\n    InvalidSnapshotSequenceNumber,\n\n    #[error(\"Unexpected error\")]\n    Unexpected(#[source] anyhow::Error),\n\n    #[error(\"Table snapshot persistence task failed\")]\n    TableSnapshotPersistenceTaskFailed(#[source] tokio::task::JoinError),\n\n    #[error(\"Failed to list table indices from object store\")]","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_write/src/table_index_cache.rs#L27-L63","documentation":"TableIndexCacheError::Json wraps a serde_json::Error raised while the TableIndexCache serializes or deserializes snapshot/index payloads as JSON. It means bytes read from (or data written to) the object store could not be converted to the expected Rust types, usually indicating corrupt, truncated, or schema-incompatible files.","triggerScenarios":"serde_json round-trips performed inside TableIndexCache operations, e.g. deserializing persisted snapshot/index bytes loaded during get_or_load, update_from_object_store, or startup conversion, or serializing conversion markers and index payloads.","commonSituations":"Snapshot files truncated by a prior crash, files written by an incompatible older InfluxDB 3 schema, or human edits to files in the object store snapshot directory.","solutions":["Identify the failing file from the logs/operation context and validate its JSON (e.g. jq) to confirm corruption or truncation.","Restore the corrupt file from a backup, or quarantine/remove it if it is a stale conversion artifact, then re-run initialize().","Verify all nodes run the same, compatible InfluxDB 3 version so serialized schemas match.","If it happens on a marker/metadata write, check for disk-full or quota conditions on the object store."],"exampleFix":"// before\nlet marker: TableIndexConversionCompleted = serde_json::from_slice(&bytes).unwrap();\n// after: surface a typed error instead of panicking\nlet marker: TableIndexConversionCompleted = serde_json::from_slice(&bytes)\n    .map_err(TableIndexCacheError::Json)?;","handlingStrategy":"validation","validationCode":"// sanity-check loaded JSON bytes before typed deserialization\nif bytes.is_empty() || serde_json::from_slice::<serde_json::Value>(&bytes).is_err() {\n    return Err(TableIndexCacheError::Json(serde_json::from_slice::<serde_json::Value>(&bytes).unwrap_err()));\n}","typeGuard":"fn is_valid_index_json(bytes: &[u8]) -> bool {\n    serde_json::from_slice::<serde_json::Value>(bytes).is_ok()\n}","tryCatchPattern":"match deserialize_index(&bytes) {\n    Err(TableIndexCacheError::Json(e)) => {\n        warn!(\"corrupt index payload: {e}; reloading from source snapshots\");\n        rebuild_from_snapshots().await?\n    }\n    r => r?,\n}","preventionTips":["Validate JSON files with jq before restoring them into the snapshot directory","Keep node versions homogeneous so serde schemas match","Watch for disk-full/quota alerts on the object store","Treat serde_json .unwrap() calls in conversion code as bugs to fix"],"tags":["json","serde","rust","serialization"],"backgroundTag":"json-parse-error","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"}