← Back to Pull requests

:bug: crd: use the Go field name for named fields with an empty json name #1523

Open
unknown opened this pull request with 163 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 14, 2026 16:44 UTC
Author

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/json writes such a field under its Go name (Retention), so the API server pruned it and the value was lost.

structToSchema set inline = inline || fieldName == "", which can't tell an embedded field from a named one. markers.FieldInfo.Name is empty only for embedded fields, so the fix checks that:

  • embedded field, empty json name: still inlined, same as before

  • named field, empty json name: the Go field name becomes the property name, and required/oneOf/immutable handling uses it too
  • Fields with an explicit ,inline option still inline, and an embedded field with an explicit name such as json:"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 in pkg/crd/schema_test.go. It checks that the schema has a Retention property and no top-level days, and that an embedded ,inline struct still goes into allOf`. 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

    Diff: 163 lines (+122 / -41) across 2 files Reviewer: JoelSpeed Review duration: 23765m
    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
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 35.0% (LOW) · Higher = larger blast radius
    35.0%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 18.6% · Safe to merge
    18.6%