{"record":{"id":"82b2ec2c6b32fd36","repo":"dgraph-io/dgraph","slug":"while-parsing-kv-v-got-error-v-82b2ec","errorCode":null,"errorMessage":"while parsing kv: %+v, got error: %v","messagePattern":"while parsing kv: %\\+v, got error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/predicate_move.go","lineNumber":77,"sourceCode":"\nfunc batchAndProposeKeyValues(ctx context.Context, kvs chan *pb.KVS) error {\n\tglog.Infoln(\"Receiving predicate. Batching and proposing key values\")\n\tn := groups().Node\n\tproposal := &pb.Proposal{}\n\tsize := 0\n\tvar pk x.ParsedKey\n\n\tfor kvPayload := range kvs {\n\t\tbuf := z.NewBufferSlice(kvPayload.GetData())\n\t\terr := buf.SliceIterate(func(s []byte) error {\n\t\t\tkv := &bpb.KV{}\n\t\t\tx.Check(proto.Unmarshal(s, kv))\n\t\t\tif len(pk.Attr) == 0 {\n\t\t\t\t// This only happens once.\n\t\t\t\tvar err error\n\t\t\t\tpk, err = x.Parse(kv.Key)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Errorf(\"while parsing kv: %+v, got error: %v\", kv, err)\n\t\t\t\t}\n\n\t\t\t\tif !pk.IsSchema() {\n\t\t\t\t\treturn errors.Errorf(\"Expecting first key to be schema key: %+v\", kv)\n\t\t\t\t}\n\n\t\t\t\t// Delete on all nodes. Remove the schema at timestamp kv.Version-1 and set it at\n\t\t\t\t// kv.Version. kv.Version will be the TxnTs of the predicate move.\n\t\t\t\tp := &pb.Proposal{CleanPredicate: pk.Attr, StartTs: kv.Version - 1}\n\t\t\t\tglog.Infof(\"Predicate being received: %v\", pk.Attr)\n\t\t\t\tif err := n.proposeAndWait(ctx, p); err != nil {\n\t\t\t\t\tglog.Errorf(\"Error while cleaning predicate %v %v\\n\", pk.Attr, err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tproposal.Kv = append(proposal.Kv, kv)\n\t\t\tsize += len(kv.Key) + len(kv.Value)","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/predicate_move.go#L59-L95","documentation":"batchAndProposeKeyValues (predicate move receiver on the destination leader) parses the first received KV to discover the predicate and expects the very first key to be a schema key. This error is raised inside the SliceIterate when x.Parse fails on that first KV — meaning the streamed KV batch starts with an unparseable key, so the receiver cannot determine which predicate/schema the move carries.","triggerScenarios":"During ReceivePredicate streaming, the first KV in the first payload fails x.Parse: sender sent KVs not prefixed with a valid Dgraph key, version-mismatched key encoding between source and destination Alphas, or corrupted KV bytes.","commonSituations":"Moving a tablet between clusters or versions with different key layouts; a sender-side bug/backup restore yielding malformed first key; network-level corruption of the gRPC stream payload buffer.","solutions":["Retry the predicate move; verify source and destination run identical Dgraph versions.","Re-run with verbose glog to see the offending KV and compare its key bytes with a known-good schema key prefix.","Validate the source predicate data with `dgraph debug` before moving.","If the stream is corrupted, restart both Alphas involved and re-trigger the move from Zero."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"pk, err := x.Parse(firstKV.Key)\nif err != nil {\n\treturn errors.Errorf(\"first streamed KV has invalid key: %v\", err)\n}","typeGuard":"func parsableKey(key []byte) bool {\n\t_, err := x.Parse(key)\n\treturn err == nil\n}","tryCatchPattern":"if err := batchAndProposeKeyValues(ctx, kvs); err != nil && strings.Contains(err.Error(), \"while parsing kv\") {\n\t// cancel stream, verify sender version/encoding, retry move\n}","preventionTips":["Ensure sender and receiver Alphas run identical versions","Never feed the move stream from hand-crafted KV lists","Validate the source posting directory with dgraph debug before moving","Restart interrupted moves from the beginning, not mid-stream"],"tags":["dgraph","predicate-move","key-parsing","schema"],"backgroundTag":"invalid-key-format","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}