juicedata/juicefs · error
json: %s
Error message
json: %s
What it means
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.
Source
Thrown at pkg/meta/base.go:723
cb, ok := r.msgCallbacks.callbacks[mid]
r.msgCallbacks.Unlock()
if ok {
return cb(args...)
}
return fmt.Errorf("message %d is not supported", mid)
}
func (m *baseMeta) Load(checkVersion bool) (*Format, error) {
body, err := m.en.doLoad()
if err == nil && len(body) == 0 {
err = fmt.Errorf("database is not formatted, please run `juicefs format ...` first")
}
if err != nil {
return nil, err
}
var format = new(Format)
if err = json.Unmarshal(body, format); err != nil {
return nil, fmt.Errorf("json: %s", err)
}
if checkVersion {
if err = format.CheckVersion(); err != nil {
return nil, fmt.Errorf("check version: %s", err)
}
}
if format.Tiers == nil {
format.Tiers = object.NewTiers(format.StorageClass)
}
m.setFormat(format)
return format, nil
}
func (m *baseMeta) newSessionInfo() []byte {
host, err := os.Hostname()
if err != nil {
logger.Warnf("Failed to get hostname: %s", err)
}View on GitHub (pinned to c9a67b23e8)
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
Example fix
# before: corrupt format record redis-cli GET setting # invalid JSON # after: restore from backup juicefs load redis://meta good.dump
Defensive patterns
Strategy: try-catch
Validate before calling
var f map[string]any
if err := json.Unmarshal(raw, &f); err != nil { return fmt.Errorf("format record corrupt: %w", err) } Try / catch
if _, err := meta.Load(true); err != nil { if strings.HasPrefix(err.Error(), "json:") { /* restore format record from backup */ } } Prevention
- Never hand-edit metadata records in Redis/SQL
- Dump backups before metadata maintenance operations
- Monitor metadata backend for write errors/crashes
When it happens
Trigger: 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.
Common situations: Hand-editing the format record in Redis; restoring partial metadata from a corrupted backup; concurrent writes from mismatched versions corrupting the record.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
Related errors
- corrupted session info; json error: %s
- The entry of the root inode was not found
- unknown message type %d
- load %v: %s
- existing format is broken: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/71b9704d9271b268.
Report an issue: GitHub.