{"record":{"id":"a843ed01b7d9efc5","repo":"lutzroeder/netron","slug":"invalid-lzf-compressed-data","errorCode":null,"errorMessage":"Invalid LZF compressed data.","messagePattern":"Invalid LZF compressed data\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/hdf5.js","lineNumber":1478,"sourceCode":"        }\n    }\n\n    _deflate(input) {\n        const archive = zip.Archive.open(input);\n        return archive.entries.get('').peek();\n    }\n\n    _lzf(input) {\n        let i = 0;\n        let o = 0;\n        while (i < input.length) {\n            let c = input[i++];\n            if (c < (1 << 5)) {\n                c++;\n                i += c;\n                o += c;\n                if (i > input.length) {\n                    throw new Error('Invalid LZF compressed data.');\n                }\n            } else {\n                let length = c >> 5;\n                if (i >= input.length) {\n                    throw new Error('Invalid LZF compressed data.');\n                }\n                if (length === 7) {\n                    length += input[i++];\n                    if (i >= input.length) {\n                        throw new Error('Invalid LZF compressed data.');\n                    }\n                }\n                const ref =  (o - ((c & 0x1f) << 8) - 1) - input[i++];\n                if (ref < 0) {\n                    throw new Error('Invalid LZF compressed data.');\n                }\n                o += length + 2;\n            }","sourceCodeStart":1460,"sourceCodeEnd":1496,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/hdf5.js#L1460-L1496","documentation":"While decompressing an LZF-compressed HDF5 chunk, the decoder encountered a literal run whose declared length (control byte < 32, encoded as c+1) runs past the end of the compressed input buffer. The compressed byte stream is malformed, so the decompressor refuses to continue rather than emit garbage data.","triggerScenarios":"Decompressing a chunk stored with HDF5's LZF filter where the literal-run length pushes the input index beyond input.length. Triggered by dataset reads (the chunk is fetched and inflated) on any dataset created with the LZF compression filter.","commonSituations":"Corrupted .h5 files where chunk payloads are damaged, files produced by a buggy/alternative LZF compressor, truncated chunk data at the end of the file, or reading data whose chunk was never fully written (crashed writer). Rarely, version mismatches in the LZF filter format itself.","solutions":["Re-create or re-export the HDF5 file, ideally verifying with h5dump that the LZF chunk decodes with the reference implementation.","If you control writing, use a well-tested LZF filter build or switch to a lossless standard filter (gzip/SZIP) that this reader also supports.","Check for truncated transfer of the file (checksum the original).","If only some chunks are bad, isolate the failing dataset and re-write just that dataset."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"function isPlausibleLzfChunk(buf, expectedDecompressedSize) {\n  // basic sanity: non-empty and not all-zero payload\n  return buf && buf.length > 0 && buf.some(b => b !== 0) && expectedDecompressedSize > 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n  data = decompressLzf(chunk, outSize);\n} catch (e) {\n  if (/Invalid LZF compressed data/.test(e.message)) {\n    // surface 'dataset chunk is corrupted' and continue with other datasets\n  } else throw e;\n}","preventionTips":["Verify written files with h5dump after creating them with the LZF filter.","Use well-established LZF filter builds when writing HDF5.","Read datasets individually so one bad chunk doesn't abort the whole file view."],"tags":["hdf5","lzf","decompression","corrupt-chunk","compression-filter"],"backgroundTag":"compressed-data-corruption","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}