Skip to content

Add omitempty to MCPGroupStatus Servers and ServerCount JSON tags #4537

@ChrisJBurns

Description

@ChrisJBurns

Summary

MCPGroupStatus.Servers and MCPGroupStatus.ServerCount are missing omitempty in their JSON struct tags, while every other +optional field in the same struct (ObservedGeneration, Phase, RemoteProxies, RemoteProxyCount, Conditions) has it. This should be fixed for consistency before the API stabilizes.

File to change

cmd/thv-operator/api/v1alpha1/mcpgroup_types.go — lines 30 and 34

Current code

// Servers lists MCPServer names in this group
// +optional
Servers []string `json:"servers"`

// ServerCount is the number of MCPServers
// +optional
ServerCount int `json:"serverCount"`

Expected code

// Servers lists MCPServer names in this group
// +optional
Servers []string `json:"servers,omitempty"`

// ServerCount is the number of MCPServers
// +optional
ServerCount int `json:"serverCount,omitempty"`

Why

  • Inconsistent with sibling fields RemoteProxies and RemoteProxyCount which both have omitempty
  • Inconsistent with every other +optional field in the struct
  • Without omitempty, empty values serialize as "servers": null and "serverCount": 0 instead of being omitted
  • Standard Kubernetes convention is omitempty for optional status fields

Verification

After making the change, run:

task lint
task test
task gen  # regenerate any generated code if needed

Confirm the CRD manifests are updated if task gen produces changes — commit those too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions