dgraph-io/dgraph · error
while parsing kv: %+v, got error: %v
Error message
while parsing kv: %+v, got error: %v
What it means
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.
Source
Thrown at worker/predicate_move.go:77
func batchAndProposeKeyValues(ctx context.Context, kvs chan *pb.KVS) error {
glog.Infoln("Receiving predicate. Batching and proposing key values")
n := groups().Node
proposal := &pb.Proposal{}
size := 0
var pk x.ParsedKey
for kvPayload := range kvs {
buf := z.NewBufferSlice(kvPayload.GetData())
err := buf.SliceIterate(func(s []byte) error {
kv := &bpb.KV{}
x.Check(proto.Unmarshal(s, kv))
if len(pk.Attr) == 0 {
// This only happens once.
var err error
pk, err = x.Parse(kv.Key)
if err != nil {
return errors.Errorf("while parsing kv: %+v, got error: %v", kv, err)
}
if !pk.IsSchema() {
return errors.Errorf("Expecting first key to be schema key: %+v", kv)
}
// Delete on all nodes. Remove the schema at timestamp kv.Version-1 and set it at
// kv.Version. kv.Version will be the TxnTs of the predicate move.
p := &pb.Proposal{CleanPredicate: pk.Attr, StartTs: kv.Version - 1}
glog.Infof("Predicate being received: %v", pk.Attr)
if err := n.proposeAndWait(ctx, p); err != nil {
glog.Errorf("Error while cleaning predicate %v %v\n", pk.Attr, err)
return err
}
}
proposal.Kv = append(proposal.Kv, kv)
size += len(kv.Key) + len(kv.Value)View on GitHub (pinned to 759e242be6)
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.
Defensive patterns
Strategy: validation
Validate before calling
pk, err := x.Parse(firstKV.Key)
if err != nil {
return errors.Errorf("first streamed KV has invalid key: %v", err)
} Type guard
func parsableKey(key []byte) bool {
_, err := x.Parse(key)
return err == nil
} Try / catch
if err := batchAndProposeKeyValues(ctx, kvs); err != nil && strings.Contains(err.Error(), "while parsing kv") {
// cancel stream, verify sender version/encoding, retry move
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- while parsing KV: %+v, got error: %v
- Expecting first key to be schema key: %+v
- illegal rune found "%c", expecting {
- JSON map is followed by illegal rune "%c"
- Malformed JSON
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/82b2ec2c6b32fd36.
Report an issue: GitHub.