{"record":{"id":"a3b3b720488b3a52","repo":"juicedata/juicefs","slug":"invalid-file-size-d-data-length-d-checksum-len","errorCode":null,"errorMessage":"invalid file size %d, data length %d, checksum length %d","messagePattern":"invalid file size (.+?), data length (.+?), checksum length (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache_file.go","lineNumber":181,"sourceCode":"\t}\n\tchecksumLength := int64(((length-1)/csBlock + 1) * 4)\n\textra := fi.Size() - int64(length)\n\tif extra < 0 {\n\t\t_ = fp.Close()\n\t\treturn nil, fmt.Errorf(\"invalid file size %d, data length %d\", fi.Size(), length)\n\t}\n\tfooterOff := int64(0)\n\tswitch {\n\tcase extra == 0:\n\t\tlevel = CsNone // data only, no footer\n\tcase extra%4 == 0:\n\t\tswitch {\n\t\tcase extra == checksumLength:\n\t\tcase extra > checksumLength:\n\t\t\tfooterOff = int64(length) + checksumLength\n\t\tdefault:\n\t\t\t_ = fp.Close()\n\t\t\treturn nil, fmt.Errorf(\"invalid file size %d, data length %d, checksum length %d\", fi.Size(), length, checksumLength)\n\t\t}\n\tdefault:\n\t\tlevel = CsNone\n\t\tfooterOff = int64(length)\n\t}\n\tcf := &cacheFile{File: fp, length: length, csLevel: level, footerOff: footerOff, size: fi.Size()}\n\treturn cf, nil\n}\n\nfunc (cf *cacheFile) ReadAt(b []byte, off int64) (n int, err error) {\n\tlogger.Tracef(\"CacheFile length %d level %s, readat off %d buffer size %d\", cf.length, cf.csLevel, off, len(b))\n\tdefer func() {\n\t\tlogger.Tracef(\"CacheFile readat returns n %d err %s\", n, err)\n\t}()\n\tif cf.csLevel == CsNone || cf.csLevel == CsFull && (off != 0 || len(b) != cf.length) {\n\t\treturn cf.File.ReadAt(b, off)\n\t}\n\tvar rb = b     // read buffer","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache_file.go#L163-L199","documentation":"Returned by openCacheFile when the on-disk file is larger than the data but the extra bytes are fewer than the expected checksum length and not a valid footer layout — the file does not match any known cache format combination of data+checksum+footer.","triggerScenarios":"Thrown at pkg/chunk/disk_cache_file.go:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Discard the malformed cache file; it will be rewritten on next caching","Rule out mixed client versions using incompatible cache formats on the same dir"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}