Skip to content

fix(unique): prevent nil pointer panic in verifyUniqueWithinMutation#9677

Merged
matthewmcneely merged 1 commit intodgraph-io:mainfrom
shaunpatterson:sp/issue-9670
Apr 7, 2026
Merged

fix(unique): prevent nil pointer panic in verifyUniqueWithinMutation#9677
matthewmcneely merged 1 commit intodgraph-io:mainfrom
shaunpatterson:sp/issue-9670

Conversation

@shaunpatterson
Copy link
Copy Markdown
Contributor

Summary

  • Fix nil pointer dereference in verifyUniqueWithinMutation and addQueryIfUnique when a mutation batch contains a UID edge (ObjectValue is nil) on a @unique predicate
  • Add nil checks for ObjectValue in 3 locations before calling dql.TypeValFrom()
  • All 3 alphas crash simultaneously because the same mutation is replicated via Raft

Test plan

  • Added 2 regression tests that panic without the fix and pass with it
  • TestVerifyUniqueWithinMutationBoundsChecks/nil_ObjectValue_should_not_panic
  • TestVerifyUniqueWithinMutationBoundsChecks/nil_ObjectValue_mixed_with_value_NQuad_should_not_panic
  • All existing tests pass

Fixes #9670

🤖 Generated with Claude Code

@shaunpatterson shaunpatterson requested a review from a team as a code owner April 7, 2026 01:43
…graph-io#9670)

When a mutation batch contains a UID edge (ObjectValue is nil) on a
predicate marked @unique, verifyUniqueWithinMutation and
addQueryIfUnique call dql.TypeValFrom(pred.ObjectValue) without a nil
check, causing a nil pointer dereference that crashes the alpha.

This affects all replicas since the same mutation is replicated via Raft,
causing simultaneous crashes across the entire cluster.

The fix adds nil checks for ObjectValue in three locations:
- addQueryIfUnique: skip building unique-check query for UID edges
- verifyUniqueWithinMutation: skip pred1 and pred2 comparisons when
  ObjectValue is nil

Fixes dgraph-io#9670

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@matthewmcneely matthewmcneely merged commit 1cbd7ea into dgraph-io:main Apr 7, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Dgraph v25.1.0 alpha Crashing

2 participants