{"record":{"id":"5aaf84d931b96fe9","repo":"dgraph-io/dgraph","slug":"startuid-length-8-for-key-q-parsed-key-v","errorCode":null,"errorMessage":"StartUid length != 8 for key: %q, parsed key: %+v","messagePattern":"StartUid length != 8 for key: %q, parsed key: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/keys.go","lineNumber":580,"sourceCode":"\n\tp.ByteType = k[0]\n\tk = k[1:]\n\n\tswitch p.ByteType {\n\tcase ByteData, ByteReverse:\n\t\tif len(k) < 8 {\n\t\t\treturn p, errors.Errorf(\"uid length < 8 for key: %q, parsed key: %+v\", key, p)\n\t\t}\n\t\tp.Uid = binary.BigEndian.Uint64(k)\n\t\tif p.Uid == 0 {\n\t\t\treturn p, errors.Errorf(\"Invalid UID with value 0 for key: %v\", key)\n\t\t}\n\t\tif !p.HasStartUid {\n\t\t\tbreak\n\t\t}\n\n\t\tif len(k) != 16 {\n\t\t\treturn p, errors.Errorf(\"StartUid length != 8 for key: %q, parsed key: %+v\", key, p)\n\t\t}\n\n\t\tk = k[8:]\n\t\tp.StartUid = binary.BigEndian.Uint64(k)\n\tcase ByteIndex:\n\t\tif !p.HasStartUid {\n\t\t\tp.Term = string(k)\n\t\t\tbreak\n\t\t}\n\n\t\tif len(k) < 8 {\n\t\t\treturn p, errors.Errorf(\"StartUid length < 8 for key: %q, parsed key: %+v\", key, p)\n\t\t}\n\n\t\tterm := k[:len(k)-8]\n\t\tstartUid := k[len(k)-8:]\n\t\tp.Term = string(term)\n\t\tp.StartUid = binary.BigEndian.Uint64(startUid)","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/x/keys.go#L562-L598","documentation":"Error returned by x/keys.go while parsing a key when the StartUid portion of the key does not have the expected 8-byte length. The raw key and parsed structure are reported via %q and %+v. Indicates a corrupt or malformed key; fix by correcting or regenerating the key data.","triggerScenarios":"Calling Parse/IsDropOpKey with a ByteData or ByteReverse key of length != 16 where HasStartUid is true (the key's type byte indicates start-uid layout).","commonSituations":"Truncated keys from corrupted storage, manually assembled byte keys of the wrong length, or version-mismatched key encodings between Dgraph components.","solutions":["Verify the key is exactly 16 bytes for start-uid data keys (hex.Dump the key)","Regenerate the key using the package's key-construction helpers","Check for version skew between nodes/writers encoding keys","If from disk, suspect corruption and restore from backup"],"exampleFix":"// before: 12-byte data key with start uid\nkey := buf[:12]\np, err := x.Parse(key) // StartUid length != 8\n// after\nkey := buf[:16] // 8-byte UID + 8-byte StartUid\np, err := x.Parse(key)","handlingStrategy":"validation","validationCode":"if len(key) != 17 { return fmt.Errorf(\"data+startuid key must be 17 bytes, got %d\", len(key)) }\nok, err := x.IsDropOpKey(key)","typeGuard":"func isStartUidDataKey(key []byte) bool { return len(key) == 17 }","tryCatchPattern":null,"preventionTips":["Use x.Key helpers that guarantee 16-byte payload for start-uid keys","Assert key lengths in unit tests for fixtures","Pin a single Dgraph version across writers/readers"],"tags":["go","badger","key-parsing"],"backgroundTag":"malformed-key-length","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}