{"record":{"id":"2adb0ab4bcf195eb","repo":"facebook/flow","slug":"failed-to-deserialize-type-sig-module","errorCode":null,"errorMessage":"failed to deserialize type sig Module","messagePattern":"failed to deserialize type sig Module","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_heap_serialization/src/lib.rs","lineNumber":99,"sourceCode":"    let decompressed = decompress(bytes);\n    let (table, _): (PackedALocTable, _) =\n        bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())\n            .expect(\"failed to deserialize PackedALocTable\");\n    Arc::new(table)\n}\n\npub fn serialize_type_sig(module: &Module<Loc>) -> Vec<u8> {\n    let bytes = bincode::serde::encode_to_vec(module, bincode::config::legacy())\n        .expect(\"failed to serialize type sig Module\");\n    compress(&bytes)\n}\n\npub fn deserialize_type_sig(file_key: &FileKey, bytes: &[u8]) -> Arc<Module<Loc>> {\n    let decompressed = decompress(bytes);\n    set_file_key(file_key);\n    let (module, _): (Module<Loc>, _) =\n        bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())\n            .expect(\"failed to deserialize type sig Module\");\n    clear_file_key();\n    Arc::new(module)\n}\n\npub fn serialize_file_sig(file_sig: &FileSig) -> Vec<u8> {\n    let bytes = bincode::serde::encode_to_vec(file_sig, bincode::config::legacy())\n        .expect(\"failed to serialize FileSig\");\n    compress(&bytes)\n}\n\npub fn deserialize_file_sig(file_key: &FileKey, bytes: &[u8]) -> Arc<FileSig> {\n    let decompressed = decompress(bytes);\n    set_file_key(file_key);\n    let (file_sig, _): (FileSig, _) =\n        bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())\n            .expect(\"failed to deserialize FileSig\");\n    clear_file_key();\n    Arc::new(file_sig)","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_heap_serialization/src/lib.rs#L81-L117","documentation":"Panics when bincode fails to decode a type-sig Module from decompressed bytes. The decoder sets the file_key thread-local first because Module<Loc> deserialization resolves source locations against it. A mismatch between the bytes' provenance (version/layout/file) and the current decoder is the failure mode.","triggerScenarios":"deserialize_type_sig on signature-cache bytes written by a different flow build; type signature schema changes without cache invalidation; bytes decoded with a file_key that doesn't match the serialized Loc offsets.","commonSituations":"Reusing a sig cache after upgrading flow; multi-checkout workspaces sharing one cache dir; CI caches persisted across toolchain bumps.","solutions":["Invalidate the signature cache so type sigs are recomputed","Tie cache directories to the flow version (or hash of serialized type layouts)","Regenerate any serialized test fixtures after editing Module or Loc serialization"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    flow_heap_serialization::deserialize_type_sig(&file_key, &bytes)\n})) {\n    Ok(m) => m,\n    Err(_) => { invalidate_sig_cache(); recompute_sig(&file_key)? }\n}","preventionTips":["Version-stamp signature caches by binary version or schema hash","Regenerate fixtures after editing Module<Loc> or TolerableError serialization","Load sig caches under the same file_key they were written with"],"tags":["rust","bincode","serialization","type-signature","saved-state"],"backgroundTag":"bincode-decode-error","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-08-23T11:17:13.642Z"}