{"record":{"id":"467bb4907f2ebe69","repo":"juicedata/juicefs","slug":"read-stage-footer-header-w","errorCode":null,"errorMessage":"read stage footer header: %w","messagePattern":"read stage footer header: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache_file.go","lineNumber":88,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\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}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache_file.go#L70-L106","documentation":"Returned by stageFooter.unmarshal when reading the 4-byte staged-file footer header at the expected offset fails (I/O error). The footer records which tier a staged cache file belongs to; if it cannot be read the staged file cannot be trusted for upload.","triggerScenarios":"Thrown at pkg/chunk/disk_cache_file.go:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Discard the damaged staged cache file so it can be re-staged and uploaded","Check disk health of the cache directory"],"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"}