{"record":{"id":"0e17dc62ec9302a6","repo":"juicedata/juicefs","slug":"invalid-stage-footer-magic-04x","errorCode":null,"errorMessage":"invalid stage footer magic %#04x","messagePattern":"invalid stage footer magic %#04x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache_file.go","lineNumber":91,"sourceCode":"\n\tbuff := make([]byte, 0, 4+len(data))\n\tbuff = binary.BigEndian.AppendUint16(buff, stageFooterMagic)\n\tbuff = binary.BigEndian.AppendUint16(buff, uint16(len(data)))\n\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}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache_file.go#L73-L109","documentation":"Returned by stageFooter.unmarshal when the staged-file footer magic number does not match stageFooterMagic. The file is not a valid staged cache file (corruption or foreign content), so its tier information cannot be recovered.","triggerScenarios":"Thrown at pkg/chunk/disk_cache_file.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the corrupted staged file; it will be re-created on next staging","Investigate cache disk reliability if it recurs"],"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"}