← Back to Pull requests

fix(utils): avoid nil pointer dereference in RemoveNotFoundDatasetRef #6272

Closed
unknown closed this pull request without merging on Nov 20, 2026 02:27 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 07:04 UTC
Author

Ⅰ. Describe what this PR does

RemoveNotFoundDatasetRef panics with a nil pointer dereference when looking up a reference dataset fails with a non-NotFound error.

In the loop, the result of GetDataset is assigned to a variable named dataset, which shadows the function's dataset argument:

dataset, err := GetDataset(client, namespacedName[1], namespacedName[0])
if err != nil && IgnoreNotFound(err) != nil {
    log.Error(err, "Failed to get reference dataset", "DatasetDeleteError", datasetRefName)
    return dataset.Status.DatasetRef, err   // dataset is nil here
}

GetDataset returns a nil *Dataset on error, so dataset.Status.DatasetRef dereferences nil and panics. This path is reached from reconcileDatasetDeletion (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 refDataset so it no longer shadows the argument, and returns the original datasetRef list 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 TestRemoveNotFoundDatasetRefGetError in pkg/utils/dataset_reference_test.go. It uses a client interceptor to force Get to return a non-NotFound (internal) error and asserts that the original datasetRef list is returned together with the error, without panicking. The test panics before the fix and passes after.

Ⅳ. Describe how to verify it

go test ./pkg/utils/ -run TestRemoveNotFoundDatasetRef -count=1

Before the fix, TestRemoveNotFoundDatasetRefGetError fails with panic: runtime error: invalid memory address or nil pointer dereference at dataset_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.

Diff: 283 lines (+212 / -71) across 3 files Reviewer: cheyang Review duration: 2603m
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
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.7% (MEDIUM) · Higher = larger blast radius
39.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.7% · Safe to merge
15.7%