{"record":{"id":"dbf27a288b3385ac","repo":"facebook/flow","slug":"failed-to-deserialize-imports","errorCode":null,"errorMessage":"failed to deserialize Imports","messagePattern":"failed to deserialize Imports","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_heap_serialization/src/lib.rs","lineNumber":144,"sourceCode":"pub fn deserialize_exports(bytes: &[u8]) -> Arc<Exports> {\n    let decompressed = decompress(bytes);\n    let (exports, _): (Exports, _) =\n        bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())\n            .expect(\"failed to deserialize Exports\");\n    Arc::new(exports)\n}\n\npub fn serialize_imports(imports: &Imports) -> Vec<u8> {\n    let bytes = bincode::serde::encode_to_vec(imports, bincode::config::legacy())\n        .expect(\"failed to serialize Imports\");\n    compress(&bytes)\n}\n\npub fn deserialize_imports(bytes: &[u8]) -> Arc<Imports> {\n    let decompressed = decompress(bytes);\n    let (imports, _): (Imports, _) =\n        bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())\n            .expect(\"failed to deserialize Imports\");\n    Arc::new(imports)\n}\n\npub fn serialize_file_sig_with_errors(\n    file_sig: &FileSig,\n    errors: &[TolerableError<Loc>],\n) -> Vec<u8> {\n    let bytes = bincode::serde::encode_to_vec((file_sig, errors), bincode::config::legacy())\n        .expect(\"failed to serialize FileSig with errors\");\n    compress(&bytes)\n}\n\npub fn deserialize_file_sig_with_errors(\n    file_key: &FileKey,\n    bytes: &[u8],\n) -> (Arc<FileSig>, Arc<[TolerableError<Loc>]>) {\n    let decompressed = decompress(bytes);\n    set_file_key(file_key);","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_heap_serialization/src/lib.rs#L126-L162","documentation":"Panics when bincode fails to decode an Imports record from decompressed bytes. Imports entries live in the same heap-cache family as Exports (no file_key involved); the decode must consume the slice exactly, and any leftover/garbage from corruption or schema drift makes decode_from_slice return Err, which this expect escalates to a panic.","triggerScenarios":"deserialize_imports on cache bytes that are truncated, corrupted, or written by a flow build with a different Imports layout; feeding the wrong record type's bytes.","commonSituations":"Saved states shared across flow versions; partial writes from killed processes; stale CI caches after toolchain changes.","solutions":["Delete the imports cache/saved state to force recomputation","Version cache directories per flow build","Ensure single-writer, atomic-write discipline for cache files"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    flow_heap_serialization::deserialize_imports(&bytes)\n})) {\n    Ok(i) => i,\n    Err(_) => { invalidate_saved_state(); recompute_imports()? }\n}","preventionTips":["Invalidate imports caches across version changes","Write records atomically (temp + rename)","Keep one writer per cache entry to avoid interleaved bytes"],"tags":["rust","bincode","serialization","imports","saved-state"],"backgroundTag":"bincode-decode-error","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}