{"record":{"id":"8d2c722c2417a34e","repo":"juicedata/juicefs","slug":"failed-to-create-message-by-type-d-w","errorCode":null,"errorMessage":"failed to create message by type %d: %w","messagePattern":"failed to create message by type (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/backup.go","lineNumber":369,"sourceCode":"\t\treturn fmt.Errorf(\"failed to read segment type: %v\", err)\n\t}\n\n\tif s.typ == BakEOS {\n\t\treturn errBakEOF\n\t}\n\n\tif err := binary.Read(r, binary.BigEndian, &s.len); err != nil {\n\t\treturn fmt.Errorf(\"failed to read segment %s length: %v\", s, err)\n\t}\n\tdata := make([]byte, s.len)\n\tn, err := r.Read(data)\n\tif err != nil && n != int(s.len) {\n\t\treturn fmt.Errorf(\"failed to read segment value: err %v, read len %d, expect len %d\", err, n, s.len)\n\t}\n\n\tmsg, err := getMessageFromType(int(s.typ))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create message by type %d: %w\", s.typ, err)\n\t}\n\tif err = proto.Unmarshal(data, msg); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal segment msg %d: %w\", s.typ, err)\n\t}\n\ts.val = msg\n\treturn nil\n}\n\ntype DumpOption struct {\n\tKeepSecret bool\n\tThreads    int\n\tProgress   func(name string, cnt int)\n}\n\nfunc (opt *DumpOption) check() *DumpOption {\n\tif opt == nil {\n\t\topt = &DumpOption{}\n\t}","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/backup.go#L351-L387","documentation":"During backup file loading, Unmarshal reads a protobuf segment whose type byte must map to a known protobuf message via getMessageFromType. This error wraps the failure to instantiate that message, typically because the segment type is unknown/unsupported in this client version or the backup stream is corrupt. It indicates the backup cannot be parsed by this binary.","triggerScenarios":"Loading a dump/backup file whose segment s.typ is not recognized by getMessageFromType; reading a backup produced by a newer JuiceFS version that introduced message types this client does not know; corrupted backup data altering the type byte.","commonSituations":"Restoring a backup taken with a newer JuiceFS release onto an older client; transferring a truncated or corrupted dump file between environments; mixing versions in disaster-recovery workflows.","solutions":["Upgrade the JuiceFS client to a version that supports the segment type in the backup file","Verify the backup file integrity (re-transfer, check checksums/size) and re-dump from the metadata engine if corrupt","Regenerate the backup with the current client version and retry load"],"exampleFix":"// before: older client fails to load backup\njuicefs load sqlite3://old.db backup.dump\n// after: upgrade client first\njuicefs version  # ensure >= version that created the dump\njuicefs load sqlite3://old.db backup.dump","handlingStrategy":"validation","validationCode":"if seg.typ > maxKnownSegmentType { return fmt.Errorf(\"unsupported segment type %d; upgrade client\", seg.typ) }","typeGuard":"func knownSegmentType(t byte) bool { _, err := getMessageFromType(int(t)); return err == nil }","tryCatchPattern":"if err := loadBackup(f); err != nil { if strings.Contains(err.Error(), \"failed to create message by type\") { /* upgrade client or regenerate dump */ } }","preventionTips":["Keep client versions in sync with the version that produced backups","Checksum dump files when transferring between hosts","Test backup restores regularly in a staging environment"],"tags":["protobuf","backup","version-compatibility"],"backgroundTag":"protobuf-unmarshal-failed","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"}