Repository navigation
fix(operator): move vmcp embedding defaulting out of Validate - #7053
Conversation
VirtualMCPServer.Validate mutated the cached object by filling Spec.Config.Optimizer, a hidden defaulting that never reached the API. Add ApplyDefaults for the embedding optimizer default, make Validate pure, and call ApplyDefaults from the controller validateSpec before Validate so existing behavior is preserved. Add regressions for Validate not mutating and ApplyDefaults filling only the nil optimizer.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Exercise controller-side defaulting through validateSpec before checking the embedding URL. Avoid shadowing the vmcp import and cover preservation of explicit optimizer settings and repeated defaulting. Update the stale validation-side defaulting comment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7053 +/- ##
==========================================
- Coverage 80.76% 80.70% -0.06%
==========================================
Files 859 859
Lines 87914 87915 +1
==========================================
- Hits 71001 70956 -45
- Misses 16908 16954 +46
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Bring in the upstream codespell correction for percent-encoded Unicode resource URI examples, together with the v0.62.0 release baseline.
Summary
VirtualMCPServer.Validate()filled the defaultSpec.Config.Optimizerwhile validating. Validate runs on a cached object, so the default never reached the API and callers could not tell validation from defaulting.ApplyDefaults()and makeValidate()pure; the controller callsApplyDefaults()beforeValidate()so the existing behaviour is preserved.Fixes #4628
Type of change
Test plan
go test ./cmd/thv-operator/api/v1beta1 -count=1passes; controllers package compiles)task test-e2e)go veton both packages andgofmtclean)New regressions assert that
Validate()leavesOptimizernil (and reports the same validation result), and thatApplyDefaults()fills only the nil optimizer when an embedding server ref is set. The existing test that relied on the mutation now callsApplyDefaults()explicitly.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Changes
virtualmcpserver_types.goApplyDefaults();Validate()no longer mutates the optimizervirtualmcpserver_types_test.govirtualmcpserver_controller.goApplyDefaults()beforeValidate()invalidateSpecDoes this introduce a user-facing change?
No. The default optimizer is still applied before reconciliation; it is now applied explicitly instead of as a side effect of validation.
Implementation plan
Approved implementation plan
validateEmbeddingServerand identify the controller call site.ApplyDefaults()with the same guard (embedding server ref set, optimizer nil).Validate()non-mutating and callApplyDefaults()fromvalidateSpecbeforeValidate().Special notes for reviewers
Validate()keeps returning the same errors; only the side effect is gone. A caller that relied onValidate()to populate the optimizer must now callApplyDefaults()(the controller does).