← Back to Pull requests

fix: avoid nil pointer dereference in CacheRuntime configmap builder #6157

Closed
unknown closed this pull request without merging on Aug 17, 2026 05:47 UTC
View on GitHub
unknown unknown commented on Aug 09, 2026 03:26 UTC
Author

I. Describe what this PR does

CacheRuntimeClass.Topology and its Master/Worker/Client sub-fields are optional pointers, and the engine dereferences them in several places without a nil check. A class that omits a component — or omits topology altogether — panics the controller, and the Dataset never reaches Bound.

The check now lives in validateRuntimeClassTopology (validate.go), called from getRuntimeClass (runtime.go). That's the only place a CacheRuntimeClass enters the engine, so all five callers are covered: setup.go:39, cm.go:107, sync.go:50, ufs.go:97, dataload.go:56.

Guarding at the loader also picks up the dereferences at dataload.go:97, image.go:29, sync.go:190 and sync.go:214 — the first revision of this PR missed all four, and the DataLoad path still panicked. The two call sites in transform.go stay as they are, since transform_test.go builds a CacheRuntimeClass directly and never goes through the loader.

The fix covers all three components, not just Client as the issue title suggests — Master and Worker have the same unguarded dereference.

The loader also returns an explicit error for a topology that declares no component at all (topology: {}), rather than quietly producing an incomplete config.

II. Does this pull request fix one issue?

fixes #6147

III. List the added test cases

Three regression tests in pkg/ddc/cache/engine/cm_test.go:

TestGenerateRuntimeConfigDataWithMissingComponentTopology — table-driven, one case per component. Each case enables the component under test; otherwise && short-circuits and the guard never runs.
TestGenerateRuntimeConfigDataWithoutAnyComponent — table-driven, covering both topology absent and topology: {} with nothing declared.
TestGenerateDataLoadValueFileWithNilTopology — the DataLoad path, which the first revision didn't cover.
IV. Describe how to verify it
go test ./pkg/ddc/cache/engine/ \
-run 'TestGenerateRuntimeConfigData|TestGenerateDataLoadValueFile' -count=1

Before the fix the DataLoad path panics:

engine.(CacheEngine).genDataLoadValue dataload.go:97
engine.(
CacheEngine).generateDataLoadValueFile dataload.go:61

After it, ok.

Every guard was checked by removing it and confirming something turns red (baseline green before each run):

mutation result
drop Master component guard FAIL
drop Worker component guard FAIL
drop Client component guard FAIL
drop the loader guard FAIL (both tests)
drop the topology: {} clause FAIL

One caveat: TestCacheEngine has 12 pre-existing spec failures in ufs_test.go / sync_test.go on master that have nothing to do with this change, so scope runs with -run.

Also reproduced on a kind cluster beforehand — the controller restarted 31 times and the Dataset stayed in NotBound, with the panic stack pointing at the Client dereference in the configmap builder.

V. Special notes for reviews

None.

Diff: 362 lines (+271 / -91) across 4 files Reviewer: btxu-db Review duration: 11661m
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.66) × (1 − Review Confidence (0.54)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.66 · 362 lines diff across 4 files
0.66
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%
54%
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.353
Shallow Review Depth shallow_review_depth
0.289
Sensitive Paths sensitive_paths
0.066
Real PR Conversation Timeline
1 comments
"Review active on #6157"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 54.2% reviewed sensitive_module
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: 65.8% (HIGH) · Higher = larger blast radius
65.8%
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: 54.2% · Lower = rushed or shallow review
54.2%
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: 30.1% · Safe to merge
30.1%