fix(utils): avoid nil pointer dereference in RemoveNotFoundDatasetRef #6272
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 283 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.338
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6272"
general
weight: 0.35
cheyang
Ⅰ. Describe what this PR does
RemoveNotFoundDatasetRefpanics with a nil pointer dereference when looking up a reference dataset fails with a non-NotFound error.In the loop, the result of
GetDatasetis assigned to a variable nameddataset, which shadows the function'sdatasetargument:GetDatasetreturns a nil*Dataseton error, sodataset.Status.DatasetRefdereferences nil and panics. This path is reached fromreconcileDatasetDeletion(pkg/controllers/v1alpha1/dataset/dataset_controller.go), so any transient API server error while resolving a referenced dataset crashes the controller during deletion reconcile.The fix renames the per-reference variable to
refDatasetso it no longer shadows the argument, and returns the originaldatasetReflist on the error path. The caller already requeues on error and ignores the returned slice, so the existing refs are left untouched until the next reconcile.Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Added
TestRemoveNotFoundDatasetRefGetErrorinpkg/utils/dataset_reference_test.go. It uses a client interceptor to forceGetto return a non-NotFound (internal) error and asserts that the originaldatasetReflist is returned together with the error, without panicking. The test panics before the fix and passes after.Ⅳ. Describe how to verify it
Before the fix,
TestRemoveNotFoundDatasetRefGetErrorfails withpanic: runtime error: invalid memory address or nil pointer dereferenceatdataset_reference.go. After the fix it passes.Ⅴ. Special notes for reviews
The change is limited to not dereferencing the nil dataset on the error path and preserving the caller's existing behavior (requeue, leave refs unchanged). No functional change on the success or NotFound paths.