Skip to content

vMCP: camelCase the config - #3195

Merged
jerm-dro merged 9 commits into
mainfrom
jerm/2026-01-05-camelCaseConfig
Jan 6, 2026
Merged

jerm-dro merged 9 commits into
mainfrom
jerm/2026-01-05-camelCaseConfig

Conversation

@jerm-dro

@jerm-dro jerm-dro commented Jan 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR standardizes all configuration struct field tags to use camelCase naming, making the configuration format consistent and Kubernetes-friendly. This is part of the ongoing effort to simplify the VirtualMCPServer configuration architecture (#3125).

Changes

Configuration Structs

  • pkg/vmcp/config/config.go: Updated all json and yaml tags to use camelCase (e.g., groupRef, incomingAuth, conflictResolution, compositeTools)
  • pkg/vmcp/auth/types/types.go: Updated field tags to camelCase while keeping strategy type values as snake_case (header_injection, token_exchange)
  • pkg/telemetry/config.go: Added missing yaml tags (previously only had json tags)
  • pkg/audit/config.go: Updated field tags to camelCase (eventTypes, excludeEventTypes, includeRequestData, etc.)

Testing

  • pkg/vmcp/config/config_test.go: Added TestConfigFieldTagsAreCamelCase that recursively validates all Config fields have yaml tags with proper camelCase naming
  • Updated test fixtures across multiple test files to use camelCase YAML keys

Documentation

  • cmd/vmcp/README.md: Updated all YAML examples to camelCase
  • examples/vmcp-config.yaml: Updated complete example config
  • docs/middleware.md: Updated audit configuration examples and table
  • swagger docs regenerated

Key Design Decisions

  1. Keys are camelCase, values remain snake_case: Field names like incomingAuth, tokenExchange use camelCase, but strategy type values like "header_injection" and "token_exchange" remain snake_case. Changing the values is riskier and should be its own change.

  2. Consistent json/yaml tags: All fields now have matching json and yaml tags to ensure consistent serialization regardless of format.

  3. Automated validation: The new TestConfigFieldTagsAreCamelCase test prevents future regressions by checking all exported fields in the Config struct tree.

Related Issues


@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 5, 2026
@codecov

codecov Bot commented Jan 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.47619% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.09%. Comparing base (5fd5ef6) to head (3ca1700).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/config/validator.go 28.57% 25 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3195      +/-   ##
==========================================
- Coverage   57.10%   57.09%   -0.01%     
==========================================
  Files         346      346              
  Lines       34304    34304              
==========================================
- Hits        19588    19587       -1     
  Misses      13096    13096              
- Partials     1620     1621       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 5, 2026
Base automatically changed from jerm/2025-12-23-delete-raw-config to main January 5, 2026 21:19
Signed-off-by: Jeremy Drouillard <[email protected]>
Signed-off-by: Jeremy Drouillard <[email protected]>
Signed-off-by: Jeremy Drouillard <[email protected]>
Signed-off-by: Jeremy Drouillard <[email protected]>
Signed-off-by: Jeremy Drouillard <[email protected]>
Signed-off-by: Jeremy Drouillard <[email protected]>
Signed-off-by: Jeremy Drouillard <[email protected]>
@jerm-dro
jerm-dro force-pushed the jerm/2026-01-05-camelCaseConfig branch from f222548 to 37cb863 Compare January 5, 2026 21:20
@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 5, 2026
Signed-off-by: Jeremy Drouillard <[email protected]>
@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 5, 2026
@jerm-dro
jerm-dro requested review from JAORMX, jhrozek and yrobla January 5, 2026 21:37
@jerm-dro
jerm-dro marked this pull request as ready for review January 5, 2026 21:38
@jhrozek

jhrozek commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

The camelCase migration looks good but I noticed it's not complete - there are still some mismatches between the CRDs and CLI that will break config conversion.

partialFailureMode: The CRD enum at virtualmcpserver_types.go:420 still uses best_effort but the validator expects bestEffort. Anyone using partialFailureMode: best_effort in their CR will hit validation errors.

Strategy types: The constants in types.go are still header_injection and token_exchange, but the CRD enum uses headerInjection and tokenExchange. Same issue.

Test: defaults_test.go uses "best_effort" which the validator would reject.

To fix this completely you'd need to update:

  • virtualmcpserver_types.go:420 → Enum=fail;bestEffort
  • virtualmcpserver_types.go:118 → Enum=discovered;externalAuthConfigRef
  • virtualmcpserver_types.go:604 → change the constant to "externalAuthConfigRef"
  • types.go:21,26 → "headerInjection" and "tokenExchange"

That'll ripple through ~40 test files that use these strings directly, plus docs and examples.

Do you want to include these fixes in this PR or handle them separately?

@jerm-dro

jerm-dro commented Jan 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

The camelCase migration looks good but I noticed it's not complete - there are still some mismatches between the CRDs and CLI that will break config conversion.

partialFailureMode: The CRD enum at virtualmcpserver_types.go:420 still uses best_effort but the validator expects bestEffort. Anyone using partialFailureMode: best_effort in their CR will hit validation errors.

Strategy types: The constants in types.go are still header_injection and token_exchange, but the CRD enum uses headerInjection and tokenExchange. Same issue.

Test: defaults_test.go uses "best_effort" which the validator would reject.

To fix this completely you'd need to update:

  • virtualmcpserver_types.go:420 → Enum=fail;bestEffort
  • virtualmcpserver_types.go:118 → Enum=discovered;externalAuthConfigRef
  • virtualmcpserver_types.go:604 → change the constant to "externalAuthConfigRef"
  • types.go:21,26 → "headerInjection" and "tokenExchange"

That'll ripple through ~40 test files that use these strings directly, plus docs and examples.

Do you want to include these fixes in this PR or handle them separately?

@jhrozek

best_effort and the constants in types.go are all values, not field names. I expect this to work but result in minor annoyance due to the inconsistent casing.

Anyone using partialFailureMode: best_effort in their CR will hit validation errors.

What validation are you referring to? I don't think there will be validation errors with your example. I only modified the validator error strings when they reference the field names. I did not change assertions about the values.

I was planning on updating the values in a follow-up PR, because I found mixing the keys and values into the same PR was also confusing.

edit: I do see there are some issues with the kubebuilder enums not matching the casing on the config side. That will continue to work, because this PR doesn't delete the conversion code. Before deleting the conversion code, we'll have to make these values the same.

@jerm-dro
jerm-dro merged commit c1167f5 into main Jan 6, 2026
@jerm-dro
jerm-dro deleted the jerm/2026-01-05-camelCaseConfig branch January 6, 2026 00:20
jhrozek added a commit that referenced this pull request Apr 15, 2026
The camelCase config migration (PR #3195) accidentally changed the
accepted enum value from "best_effort" to "bestEffort" in the validator,
but the CRD still defines the enum as "best_effort". This made it
impossible to enable best-effort partial failure mode — the CRD blocks
"bestEffort" at admission and the validator blocks "best_effort" at
runtime.

Fixes #4856

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
jhrozek added a commit that referenced this pull request Apr 16, 2026
The camelCase config migration (PR #3195) accidentally changed the
accepted enum value from "best_effort" to "bestEffort" in the validator,
but the CRD still defines the enum as "best_effort". This made it
impossible to enable best-effort partial failure mode — the CRD blocks
"bestEffort" at admission and the validator blocks "best_effort" at
runtime.

Fixes #4856

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants