{"record":{"id":"71b9704d9271b268","repo":"juicedata/juicefs","slug":"json-s","errorCode":null,"errorMessage":"json: %s","messagePattern":"json: %s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/base.go","lineNumber":723,"sourceCode":"\tcb, ok := r.msgCallbacks.callbacks[mid]\n\tr.msgCallbacks.Unlock()\n\tif ok {\n\t\treturn cb(args...)\n\t}\n\treturn fmt.Errorf(\"message %d is not supported\", mid)\n}\n\nfunc (m *baseMeta) Load(checkVersion bool) (*Format, error) {\n\tbody, err := m.en.doLoad()\n\tif err == nil && len(body) == 0 {\n\t\terr = fmt.Errorf(\"database is not formatted, please run `juicefs format ...` first\")\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar format = new(Format)\n\tif err = json.Unmarshal(body, format); err != nil {\n\t\treturn nil, fmt.Errorf(\"json: %s\", err)\n\t}\n\tif checkVersion {\n\t\tif err = format.CheckVersion(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"check version: %s\", err)\n\t\t}\n\t}\n\tif format.Tiers == nil {\n\t\tformat.Tiers = object.NewTiers(format.StorageClass)\n\t}\n\tm.setFormat(format)\n\treturn format, nil\n}\n\nfunc (m *baseMeta) newSessionInfo() []byte {\n\thost, err := os.Hostname()\n\tif err != nil {\n\t\tlogger.Warnf(\"Failed to get hostname: %s\", err)\n\t}","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/base.go#L705-L741","documentation":"baseMeta.Load unmarshals the stored format record (JSON) into a Format struct; if json.Unmarshal fails, this error wraps the JSON decode failure. It means the format record in the metadata engine is malformed or was written by an incompatible writer.","triggerScenarios":"The `setting` key in the metadata engine contains invalid or truncated JSON; manual edits to Redis/SQL rows; partially failed writes from a crashed client.","commonSituations":"Hand-editing the format record in Redis; restoring partial metadata from a corrupted backup; concurrent writes from mismatched versions corrupting the record.","solutions":["Re-run `juicefs format` on a fresh database, or restore a known-good backup with `juicefs load`","Inspect the stored format record (e.g. GET setting in Redis) and fix invalid JSON","Verify storage medium integrity; rule out corruption of the metadata backend"],"exampleFix":"# before: corrupt format record\nredis-cli GET setting  # invalid JSON\n# after: restore from backup\njuicefs load redis://meta good.dump","handlingStrategy":"try-catch","validationCode":"var f map[string]any\nif err := json.Unmarshal(raw, &f); err != nil { return fmt.Errorf(\"format record corrupt: %w\", err) }","typeGuard":null,"tryCatchPattern":"if _, err := meta.Load(true); err != nil { if strings.HasPrefix(err.Error(), \"json:\") { /* restore format record from backup */ } }","preventionTips":["Never hand-edit metadata records in Redis/SQL","Dump backups before metadata maintenance operations","Monitor metadata backend for write errors/crashes"],"tags":["json","metadata","corruption"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}