Skip to content

Change GroupRef from bare string to typed struct for API consistency #4634

@ChrisJBurns

Description

@ChrisJBurns

Summary

GroupRef is a bare string while every other cross-CRD reference in the API uses a typed struct. This inconsistency prevents extending GroupRef with additional fields (like namespace) without a breaking change, and blocks struct-level validation markers.

Severity: MUST FIX
Area: CRD API Design
Breaking: Yes — changes wire format from groupRef: "my-group" to groupRef: {name: "my-group"}

Location

  • cmd/thv-operator/api/v1alpha1/mcpserver_types.go:295
  • cmd/thv-operator/api/v1alpha1/mcpremoteproxy_types.go:130

Problem

GroupRef string `json:"groupRef,omitempty"`

Every other cross-CRD reference uses a typed struct:

  • ExternalAuthConfigRef struct { Name string }
  • ToolConfigRef struct { Name string }
  • MCPOIDCConfigReference struct { Name, Audience, Scopes }
  • EmbeddingServerRef struct { Name string }

GroupRef is the only one using a bare string.

Impact

  • Inconsistent API pattern
  • Cannot add fields like namespace to GroupRef without a breaking change
  • No struct-level validation markers possible

Recommended Fix

  1. Define type MCPGroupRef struct { Name string +""+json:"name"+""+ }
  2. Replace GroupRef string with GroupRef *MCPGroupRef on MCPServerSpec and MCPRemoteProxySpec
  3. Update controller code to access GroupRef.Name instead of GroupRef directly
  4. This is a breaking wire-format change (from string to object) — must happen before v1beta1

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiItems related to the APIbreaking-changeenhancementNew feature or requestgoPull requests that update go codekubernetesItems related to Kubernetesoperator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions