← Back to Pull requests

test: build round-trip fuzz funcs from the API version #8190

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 19, 2026 13:27 UTC
Author

<!-- No Jira issue: see "Tracking issue" below. -->

What

Replaces the per-API-version lists of randfill overrides in internal/azureapi/v/conversion_fuzz_test.go with a single coreapitesting.RoundTripFuzzFuncs(apiVersion metadataapi.APIVersion) that derives the overrides from the API version, gating each field on the version that introduced it with metadataapi.APIVersion.LT:

func(j *coreapi.CustomerPlatformProfile, c randfill.Continue) {
    fillCustomerPlatformProfile(j, c)
    if apiVersion.LT(metadataapi.APIVersionV20251223Preview) {
        // VnetIntegrationSubnetID was added in v20251223preview.
        j.VnetIntegrationSubnetID = nil
    }
    if apiVersion.LT(metadataapi.APIVersionV20261001) {
        // ContainerRegistry was added in v20261001.
        j.ContainerRegistry = coreapi.ContainerRegistryProfile{}
    }
},

Each version's TestRoundTripInternalExternalInternal is now a three-line fuzzer setup that names its own version constant. CommonRoundTripFuzzFuncs is folded into RoundTripFuzzFuncs and unexported, so there is one entry point and versions cannot drift back to hand-rolled lists.

Why

TestRoundTripInternalExternalInternal verifies that an internal coreapi object survives conversion to a versioned external type and back. Fields that postdate a given API version cannot survive that round trip, so the fuzzer has to zero them before the comparison.

Those overrides were duplicated across all five version tests. Adding a field to the latest API version meant revisiting every older version's test and appending another override — easy to forget, and the resulting failure (a 200-iteration fuzz diff on a randomly generated object) is expensive to read. Centralizing them means adding a field to the newest version now requires exactly one new apiVersion.LT(...) guard in one function.

The duplication had already drifted. The CustomerPlatformProfile override in v20251223preview, v20260630preview, and v20260901preview shadowed the CommonDeepCopyFuzzFuncs fill func for that type — randfill keeps only the last-registered func per type — and so silently dropped the type-correct ARM resource ID generation. SubnetID and NetworkSecurityGroupID in those three tests fell through to the generic azcorearm.ResourceID func, which always emits a Microsoft.RedHatOpenShift/hcpOpenShiftClusters ID, meaning a subnet field was fuzzed with a cluster-typed ID. v20240610preview avoided this by copy-pasting the base fill inline. That copy-pasted body is now extracted as fillCustomerPlatformProfile / fillOSDiskProfile and shared, so every version gets properly-typed subnet, NSG, and disk-encryption-set IDs. The conversion code passes these through as strings, so this widens fuzz coverage rather than changing any assertion.

Behavior

No production code changes — the diff is confined to test code and the test-only coreapitesting helper package. The round-trip coverage per version is unchanged except for the more realistic resource IDs noted above.

Going forward, the contract is: a field added to the newest API version gets one guard in RoundTripFuzzFuncs. Because randfill dispatches on type and keeps the last-registered func, there must be at most one func per type in that list — when a type gains a field in a new version, extend that type's existing func rather than registering a second one. This is stated in the function's doc comment.

Testing

  • Unit tests: go test -count=30 on all five internal/azureapi/v packages and internal/api/coreapi, each run seeding from a fresh rand.Int63(). Full internal module suite passes; test-integration still builds.

  • golangci-lint clean on internal/apitesting/... and internal/azureapi/....

  • Verified the version guards are load-bearing, not decorative: forcing each older version's test to pass APIVersionV20261001 makes v20240610preview, v20260630preview, and v20260901preview fail as expected.

  • No new tests added: this is a refactor of existing test infrastructure, and the five existing round-trip tests are the regression check for it.
  • Special notes for your reviewer

  • .claude/ change: .claude/skills/bootstrap-api-version/SKILL.md gains two documentation bullets so the next version bootstrap updates the version constant passed to RoundTripFuzzFuncs instead of copying override lists. Markdown only — no settings.json, no scripts, no executable commands.

  • No CI/CD configuration changes: nothing under .github/workflows/, Makefile, pipeline.yaml, or any Dockerfile is touched.

  • Forcing a wrong version into v20251223preview's test does not fail, unlike the other versions. That is pre-existing and not masking a gap: its cluster round trip calls ConvertToInternal(original), and the conversion deliberately carries unknown-to-this-version fields through from from (v20251223preview/hcpopenshiftclusters_methods.go:532-543). Its ContainerRegistry / KeyVaultType overrides were already no-ops before this change; the behavior is preserved rather than quietly altered.
  • Tracking issue

    No Jira issue. This is a self-contained cleanup of test infrastructure with no functional, API, or deployed-artifact impact, raised directly from maintenance of the API-version fuzz tests.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: cadenmarchese Review duration: 4695m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #8190"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 27.7% · Safe to merge
    27.7%
    Repository