{"record":{"id":"023a15864b63b0f4","repo":"juicedata/juicefs","slug":"invalid-stage-footer-length-d","errorCode":null,"errorMessage":"invalid stage footer length %d","messagePattern":"invalid stage footer length (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache_file.go","lineNumber":95,"sourceCode":"\tbuff = append(buff, data...)\n\treturn buff, nil\n}\n\nfunc (f *stageFooter) unmarshal(cf *cacheFile) error {\n\tif cf.footerOff == 0 {\n\t\tf.Tier = 0 // no footer, fall back to the default\n\t\treturn nil\n\t}\n\tvar hdr [4]byte\n\tif _, err := cf.File.ReadAt(hdr[:], cf.footerOff); err != nil {\n\t\treturn fmt.Errorf(\"read stage footer header: %w\", err)\n\t}\n\tif magic := binary.BigEndian.Uint16(hdr[:2]); magic != stageFooterMagic {\n\t\treturn fmt.Errorf(\"invalid stage footer magic %#04x\", magic)\n\t}\n\tsize := int64(binary.BigEndian.Uint16(hdr[2:4]))\n\tif size == 0 {\n\t\treturn fmt.Errorf(\"invalid stage footer length %d\", size)\n\t}\n\tif cf.footerOff+4+size != cf.size {\n\t\treturn fmt.Errorf(\"stage footer size mismatch: offset %d, size %d, file size %d\", cf.footerOff, size, cf.size)\n\t}\n\tbuf := make([]byte, size)\n\tif _, err := cf.File.ReadAt(buf, cf.footerOff+4); err != nil {\n\t\treturn fmt.Errorf(\"read stage footer data: %w\", err)\n\t}\n\tif err := msgpack.Unmarshal(buf, f); err != nil {\n\t\treturn err\n\t}\n\tif f.Tier > maxTierID {\n\t\tf.Tier = 0 // ignore unknown/corrupted tier, fall back to the default\n\t}\n\treturn nil\n}\n\nvar (","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache_file.go#L77-L113","documentation":"The staged cache file's footer declares a payload size of zero after the magic number was validated. Indicates the footer is truncated or corrupted (length field never written or zeroed), so the tiering metadata cannot be trusted and the footer is rejected.","triggerScenarios":"Thrown at pkg/chunk/disk_cache_file.go:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop the malformed staged cache file and let it be re-staged"],"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"}