← Back to Pull requests

test(model-registry): add upstream-aware BFF contract gate #10256

Closed
unknown closed this pull request without merging on Oct 21, 2026 10:44 UTC
View on GitHub
unknown unknown commented on Oct 15, 2026 08:18 UTC
Author

https://redhat.atlassian.net/browse/RHOAIENG-101356

Related Core BFF story: https://redhat.atlassian.net/browse/RHOAIENG-100663

Cross-package schema authorization: https://redhat.atlassian.net/browse/RHOAIENG-101357

Reviewer note: expected CI result

OpenAPI compatibility vs PR base / check is expected to fail in this PR.

This PR intentionally corrects the Model Catalog BFF OpenAPI schema. The old base schema describes responses as raw entities/lists, while the actual BFF returns them inside a required data envelope. Moving fields such as items, size, pageSize, nextPageToken, and name under data is reported as 24 breaking OpenAPI findings.

The same gate reports 8 additional findings because Model Catalog read paths document namespace as required and non-empty. The BFF runtime already rejects missing or empty values through AttachNamespace, so this is a second intentional baseline correction rather than a runtime regression.

The gate also reports 54 additional findings because the shared Error schema now matches the BFF's actual {"error":{"code","message"}} response envelope instead of documenting a flat {"code","message"} object. The current expected total is 86 findings.

The gate runs in enforce mode so the baseline transition is visible. Once this PR merges, the corrected schema becomes the new main baseline and future incompatible changes fail normally.

BFF contract vs upstream main previously exposed a real upstream mismatch: Model Registry's BFF returned Model Catalog payloads inside data, but its OpenAPI response schemas omitted that envelope. Upstream fixed this in kubeflow/hub#3351, merged as 09fc03499c281cfd05ed625aeb83b2152b71b9d6.

The new missing-namespace error test exposed a second live upstream mismatch: the BFF returns an error envelope, but upstream main still documents a flat Error object. The current run therefore fails 1/9 until kubeflow/hub#3360 merges. That upstream PR changes only the OpenAPI Error schema to match the runtime and generated BFF swagger definition.

Post-merge evidence is available in #10262:

  • OpenAPI compatibility vs PR base — success

  • BFF contract vs upstream main — success

  • Contract-Tests — success
  • The simulation is refreshed against the latest PR head before merge. Its base contains that head while its head adds only a workflow comment. It should remain red only for the upstream error-envelope mismatch until #3360 merges; then it can be rerun to prove the post-merge dashboard baseline is green. #10262 is evidence only and should not be merged.

    Problem

    The Model Registry BFF contract suite only covered the registry list endpoint, did not enable the Model Catalog mock client, and described Model Catalog responses without the BFF's data envelope. Automated upstream-sync PRs also did not run BFF contract tests, so upstream schema drift was not exercised through the dashboard consumer path.

    Two additional gaps were exposed by review:

  • The OpenAPI document reused an optional generic namespace parameter even though Model Catalog read routes reject missing or empty values at runtime.

  • The upstream-main gate validated responses against the upstream OpenAPI document, but it did not independently assert the response structure and fields that the Dashboard itself consumes.

  • The OpenAPI Error schema did not match the BFF's actual error envelope, and the suite had no Model Catalog error-response test.
  • Solution

  • Enable mocked Kubernetes, Model Registry, and Model Catalog clients for the package's contract tests.

  • Add seven Model Catalog BFF contract tests covering models, sources, filter options, labels, model details, artifacts, and a missing-namespace 400 response.

  • Correct the Model Catalog OpenAPI response schemas to include the actual data envelope.

  • Document the BFF-required namespace query parameter on all Model Catalog read paths with a catalog-specific parameter marked required: true and minLength: 1; other endpoints retain the existing optional parameter.

  • Add Dashboard-owned assertions for the required data envelope and key consumed fields, independent of the upstream OpenAPI schema.

  • Add Dashboard-owned assertions for list pagination fields (size, pageSize, and nextPageToken).

  • Correct the shared OpenAPI Error schema to document the BFF's required error envelope.

  • Add a valid OpenAPI fixture that distinguishes nullable enums which include null from those which exclude it.

  • Add a dashboard contract descriptor for the BFF Model Catalog surface.

  • Consolidate the new gates into one Contract / Model Registry workflow with two jobs:

  • - OpenAPI compatibility vs PR base
    - BFF contract vs upstream main
  • Enforce OpenAPI compatibility so breaking changes produce a red check.

  • Resolve kubeflow/model-registry@main to an exact SHA and run the dashboard BFF tests against that upstream SHA.

  • Update the central reusable workflow and documentation references to the renamed red-hat-data-services/api-contract-tests repository.

  • Scope the upstream-main gate to the nine Model Registry and Model Catalog consumer tests; dashboard-only Serving Runtime Catalog tests remain in the broad dashboard suite.

  • Run the BFF contract tests in the existing automated upstream-sync workflow.

  • Harden the shared contract matcher so missing schema references throw instead of silently validating the whole OpenAPI document, support the OpenAPI root pointer, and handle OpenAPI 3.0 nullable references.

  • - Nullable handling follows OpenAPI 3.0.3: nullable widens only an explicitly defined type; constraints such as enum retain their behavior, and $ref siblings are ignored.
    - Missing references now fail both positive and negated assertions, with regression coverage for both cases.
  • Correct invalid JSON Pointer escapes and pre-existing schema drift exposed by the stricter matcher across the Agent Ops, AutoML, AutoRAG, Core BFF, EvalHub, and Gen AI contract suites.

  • - The EvalHub and Gen AI OpenAPI response corrections are authorized by RHOAIENG-101357.
  • Correct the Gen AI LSD status schema so nullability is defined on the referenced model rather than as an ignored $ref sibling, test populated, empty, and missing-namespace error responses, and assert the populated response contains a non-null distribution object.

  • Align Gen AI Cypress user mocks with the documented UserModel.userId field.

  • Missing-reference polarity fix and regression coverage added in 6a3603a16; nullable and LSD status coverage added in b5410e675, 1fb4eaa6d, and 504702157; user mock alignment added in 5668e258e.
  • Protected File Rationale

    The .github/workflows/ changes add the Model Registry contract gates and run BFF contract tests during automated upstream-sync PRs.

    The .claude/rules/contract-tests.md change updates the contract-test examples so media-type JSON Pointer segments correctly escape / as ~1, for example application~1json. The stricter schema-reference validation made the previous unescaped examples invalid. This is a documentation correction for the shared contract-test rule, not a governance-policy change.

    Check Map

    | Check | Question it answers | Result in this PR |
    |---|---|---|
    | Test / Contract-Tests | Do the dashboard's broad mocked contract suites pass? | Pass |
    | Model Registry BFF Tests | Does the dashboard's synced Model Registry BFF pass its dedicated tests? | Pass |
    | Contract / Model Registry / OpenAPI compatibility vs PR base | Does this PR break the documented BFF OpenAPI contract relative to its base? |
    Fail intentionally |
    | Contract / Model Registry / BFF contract vs upstream main | Do the dashboard consumer tests pass against the latest upstream main BFF and OpenAPI document? |
    Fail intentionally until #3360 merges* |

    The first two checks are existing dashboard workflows. The last two are jobs in the new consolidated Contract / Model Registry workflow.

    Central Contract Tests Onboarding

    This PR onboards the Dashboard Model Registry BFF to the shared red-hat-data-services/api-contract-tests repository.

    The OpenAPI job calls the reusable workflow:

    red-hat-data-services/api-contract-tests/.github/workflows/provider-openapi-check.yml@bf7aa8c4767cfb1cfe883110f8f4d2d6a6a76bdf

    That central workflow:

    1. Checks out this dashboard PR as the provider repository.
    2. Reads packages/model-registry/.rhoai/contracts.yaml.
    3. Selects contract model-registry-bff-model-catalog-v1.
    4. Compares the PR's OpenAPI contract surface against the PR base SHA.
    5. Installs the pinned oasdiff and yq versions declared by the contract.
    6. Runs a static OpenAPI compatibility check in enforce mode.
    7. Fails the check when breaking findings are present and uploads the report.

    The 86 findings come from the intentional success-envelope, required-namespace, and error-envelope corrections described above. They are not an upstream main failure and not a mocked BFF test failure.

    Direct Upstream Main Gate

    The BFF contract vs upstream main job implements the latest-main policy:

    1. Resolve kubeflow/model-registry@main once to a full 40-character SHA.
    2. Record that SHA in the job summary.
    3. Check out Model Registry at the exact SHA.
    4. Run the dashboard contract tests against the upstream clients/ui/bff.
    5. Load the upstream clients/ui/api/openapi/mod-arch.yaml through CONTRACT_OPENAPI_PATH.
    6. Fail the dashboard PR if the consumer tests no longer pass against the latest upstream main.

    The resolved SHA makes every run reproducible and makes upstream drift attributable while still following the latest-main policy.

    The upstream gate runs the nine Model Registry and Model Catalog consumer tests. The three Serving Runtime Catalog tests remain part of the dashboard's broad contract suite because those endpoints are dashboard-specific and are not exposed by the upstream Model Registry BFF.

    The tests also include Dashboard-owned assertions for the data envelope and consumed fields. This matters because the upstream BFF and upstream OpenAPI document come from the same resolved SHA: without independent assertions, an upstream change could alter both the implementation and schema together without preserving the Dashboard's consumer expectations.

    Fullsend Review Follow-up

    Addressed the remaining Fullsend findings in 5d91855f301734d1ae23e341b98fa306aaee61d6:

  • Model Catalog endpoints now use a catalog-specific namespace parameter with required: true and minLength: 1, while other endpoints retain the existing optional parameter.

  • The Model Catalog consumer tests now assert the Dashboard-required data envelope and key fields independently of the upstream OpenAPI schema.

  • The list tests now assert the Dashboard-required pagination fields size, pageSize, and nextPageToken.

  • A missing-namespace test validates the documented 400 response and the actual error envelope.

  • The contract-test documentation now escapes / as ~1 in JSON Pointer media-type segments.
  • Validation:

  • pnpm --filter @odh-dashboard/model-registry test:contract: 14/14 passing.

  • Direct upstream-main run at 09fc03499c281cfd05ed625aeb83b2152b71b9d6: 8/9 passing; the sole failure is the known upstream Error schema mismatch fixed by #3360.

  • pnpm --filter @odh-dashboard/model-registry lint and type-check: passing.

  • PR CI: BFF contract vs upstream main is expected to fail 1/9 until #3360 merges. OpenAPI compatibility vs PR base still fails intentionally with 86 findings during this baseline transition.
  • Retroactive Bug Coverage

    I reviewed the Jira search for RHOAIENG bugs labelled cypress_found_bug. Of 223 results, 11 explicitly mention Model Registry. They fall into UI/test-selector issues, browser/runtime errors, controller finalizer or RBAC behavior, and deployment/route problems. None are OpenAPI response-schema drift, so this PR should not claim that these gates would have caught those historical bugs.

    The gates did, however, catch a live Model Catalog contract mismatch during development: upstream BFF responses used a required data envelope while the upstream OpenAPI schema omitted it. That produced failing consumer tests until kubeflow/hub#3351 corrected the upstream schema. This is the intended class of failure: implementation/OpenAPI drift that reaches the Dashboard consumer.

    One related known drift, RHOAIENG-100553, concerns Serving Runtime Catalog field names (llmInferenceServiceConfig and minimumRHOAIVersion). This initial contract intentionally scopes static compatibility and BFF tests to /api/v1/model_catalog; it would not catch that Serving Runtime Catalog drift yet. A follow-up should onboard /api/v1/serving_runtime_catalog and add consumer assertions for those fields.

    Testing

  • pnpm --filter @odh-dashboard/model-registry test:contract — 14/14 tests passing.

  • pnpm --filter @odh-dashboard/gen-ai test:contract — 29/29 tests passing.

  • Direct upstream-main run against kubeflow/model-registry@09fc03499c281cfd05ed625aeb83b2152b71b9d6 — 8/9 tests passing; the sole failure is the known upstream Error schema mismatch fixed by #3360.

  • Direct run against #3360 head d7c53f2da7649d4663d4a5f0e8f6cc7e59d87644 — 9/9 tests passing.

  • pnpm --filter @odh-dashboard/model-registry lint — passing.

  • pnpm --filter @odh-dashboard/model-registry type-check — passing.

  • Full local pnpm run test:contract — 11/11 tasks passing.

  • Contract-Tests — success

  • Full Test workflow — success

  • BFF contract vs upstream main — expected failure until #3360 merges

  • OpenAPI compatibility vs PR base — expected intentional baseline-transition failure with 86 findings.

  • Model Registry main does not currently produce committed CRDs; its controller/manifests target generated no CRD files. Generic CRD support is available centrally in api-contract-tests PR #2.
  • Merge Order

    1. The central api-contract-tests PR #2 is merged.
    2. Merge kubeflow/hub#3360, which corrects the upstream error envelope.
    3. Merge this PR, which pins the central reusable workflow by SHA.
    4. The corrected schema becomes the new main baseline; #10262 provides the green post-merge simulation.

    [RHOAIENG-100553]: https://redhat.atlassian.net/browse/RHOAIENG-100553?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJpIjoiZ2l0aHViLWNvbS1KU1cifQ%

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added compatibility checks for Model Registry catalog APIs and upstream OpenAPI updates.
    Added contract coverage for Model Registry catalog responses, including validation of successful and invalid requests.
    Bug Fixes
    Improved contract validation for nullable schemas and invalid or unresolved schema references.
    Updated evaluation job responses to return a list of jobs and no longer require benchmark details.
    Updated Gen AI user responses to include user details in a data envelope.
    Documentation
    Added guidance on Model Registry contract compatibility and running its checks.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    [RHOAIENG-101357]: https://redhat.atlassian.net/browse/RHOAIENG-101357?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: lucferbux Review duration: 8786m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). 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.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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #10256"
    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: 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: 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: 20.5% · Safe to merge
    20.5%