:bug: crd: use the Go field name for named fields with an empty json name #1523
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.35) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 163 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.305
Real PR Conversation Timeline
1 comments
"Review active on #1523"
general
weight: 0.35
JoelSpeed
A named field whose json tag has no name, like
Retention RetentionPolicy \json:",omitempty"\`, was treated as embedded and inlined into the parent schema.encoding/jsonwrites such a field under its Go name (Retention), so the API server pruned it and the value was lost.structToSchema
setinline = inline || fieldName == "", which can't tell an embedded field from a named one.markers.FieldInfo.Nameis empty only for embedded fields, so the fix checks that:Fields with an explicit ,inline
option still inline, and an embedded field with an explicit name such asjson:"foo"stays named, as it does today. No golden testdata has a named field with an empty json name, so generated output for existing types doesn't change.Added Test_Schema_NamedFieldWithEmptyJSONName
inpkg/crd/schema_test.go. It checks that the schema has aRetentionproperty and no top-leveldays, and that an embedded,inlinestruct still goes intoallOf`. The test fails without the change.I used an AI assistant while writing this change. I reviewed the code and the test and ran them locally.
Fixes #1515