{"record":{"id":"5f43fc495a314d42","repo":"dgraph-io/dgraph","slug":"unexpected-meta-d-for-key-s-5f43fc","errorCode":null,"errorMessage":"Unexpected meta %d for key %s","messagePattern":"Unexpected meta (.+?) for key (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/restore_map.go","lineNumber":566,"sourceCode":"\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tif strings.HasSuffix(update.Predicate, \"dgraph.xid\") && !update.Unique && schema.IsUniqueDgraphXid {\n\t\t\t\t\tupdate.Unique = true\n\t\t\t\t}\n\n\t\t\t\tkv.Value, err = proto.Marshal(&update)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif err := toBuffer(kv, version); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\tdefault:\n\t\t\treturn errors.Errorf(\n\t\t\t\t\"Unexpected meta %d for key %s\", kv.UserMeta[0], hex.Dump(kv.Key))\n\t\t}\n\t\treturn nil\n\t}\n\n\tmergeBuffer := func() error {\n\t\tif buf.IsEmpty() {\n\t\t\treturn nil\n\t\t}\n\t\tatomic.AddUint64(&m.bytesProcessed, uint64(buf.LenNoPadding()))\n\n\t\tm.bufLock.Lock()\n\t\tdefer m.bufLock.Unlock()\n\n\t\tx.Check2(m.buf.Write(buf.Bytes()))\n\t\tbuf.Reset()\n\n\t\tif m.buf.LenNoPadding() < mapFileSz {","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/restore_map.go#L548-L584","documentation":"During the restore map phase, each key-value item read from a backup is dispatched based on its UserMeta byte. This error is thrown in the default case of that switch when the meta byte holds a value the current Dgraph version's restore code does not recognize, meaning the backup stream contains an item type this code path cannot interpret.","triggerScenarios":"kv.UserMeta[0] contains a value other than the known meta constants (e.g. 0 for data, 1 for index/schema meta) while processing a backup via toBuffer in the mapper's item handler.","commonSituations":"Restoring a backup produced by a newer or patched Dgraph version whose writer emits extra meta types; a corrupted or truncated backup file where bytes are misaligned; manually edited or third-party-generated backup objects.","solutions":["Check that the Dgraph version performing the restore is >= the version that created the backup (restore is not backward compatible with unknown meta values).","Verify backup integrity by re-uploading or re-downloading the backup objects and comparing checksums.","Re-create the backup with a matching Dgraph version and retry the restore.","If you control the code, extend the switch in worker/restore_map.go to handle (or explicitly ignore) the new meta value instead of erroring."],"exampleFix":"// before\ndefault:\n    return errors.Errorf(\"Unexpected meta %d for key %s\", kv.UserMeta[0], hex.Dump(kv.Key))\n// after\ncase x.MetaNewKind: // handle the meta emitted by the newer backup format\n    if err := toBufferNewKind(kv, version); err != nil {\n        return err\n    }\ndefault:\n    return errors.Errorf(\"Unexpected meta %d for key %s\", kv.UserMeta[0], hex.Dump(kv.Key))","handlingStrategy":"validation","validationCode":"// before restore, scan backup kvs for known meta values\n// (conceptual): ensure kv.UserMeta[0] is one of the meta constants\n// your Dgraph version supports; otherwise the restore will abort.\nfunc metaKnown(b byte, known map[byte]bool) bool { return known[b] }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the restore binary to a Dgraph version >= the backup's writer version","Checksum backup objects after upload/download","Never hand-edit backup kv streams"],"tags":["dgraph","restore","backup-format","data-corruption"],"backgroundTag":"unknown-record-type-in-backup","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}