Add CEL validation to OIDCConfigRef and AuthzConfigRef union types#4299
Add CEL validation to OIDCConfigRef and AuthzConfigRef union types#4299ChrisJBurns merged 2 commits intomainfrom
Conversation
Misconfigurations of OIDCConfigRef and AuthzConfigRef (e.g. setting type: kubernetes but populating the configMap field) were only caught at controller reconciliation time, producing confusing errors. This adds CEL validation rules matching the existing MCPExternalAuthConfig pattern so the API server rejects invalid combinations at admission. Closes #4247 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4299 +/- ##
==========================================
- Coverage 68.77% 68.76% -0.01%
==========================================
Files 473 473
Lines 47917 47919 +2
==========================================
- Hits 32955 32952 -3
+ Misses 12309 12301 -8
- Partials 2653 2666 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jerm-dro
left a comment
There was a problem hiding this comment.
CEL rules are the right approach here, tests are thorough for individual rule violations.
Minor suggestion: consider adding a few multi-violation cases to the test matrix — e.g., type=configMap with only inline set (triggers both "missing configMap" and "extra inline"), or type=inline with inline + kubernetes set. These verify how multiple CEL violations surface to the user simultaneously. Not a blocker since every individual rule is already tested in both directions.
|
Claude finished @ChrisJBurns's task in 2m 16s —— View job • Adding multi-violation CEL test cases
|
|
@claude please create the above PR from the branch you used to commit the changes |
|
Claude finished @ChrisJBurns's task in 26s —— View job • Create PR ➔ Creating PR from branch
|
Summary
OIDCConfigRefandAuthzConfigRefuse atypediscriminator field but had no CEL validation rules — nothing prevented setting bothconfigMapandinlinesimultaneously, or omitting the required field for a given type. Validation only happened at controller reconciliation time, producing confusing error conditions instead of immediate API rejection.This adds CEL
XValidationrules following the existingMCPExternalAuthConfigSpecpattern so misconfigurations are caught at admission time by the API server.Closes #4247
Type of change
Changes
cmd/thv-operator/api/v1alpha1/mcpserver_types.goOIDCConfigRefand 2 CEL rules toAuthzConfigRefdeploy/charts/operator-crds/files/crds/*.yamldeploy/charts/operator-crds/templates/*.yamlcmd/thv-operator/test-integration/mcp-server/mcpserver_cel_validation_integration_test.goDoes this introduce a user-facing change?
Applying a manifest with a type/field mismatch (e.g.
type: kubernetesbutconfigMapset) or a missing required field (e.g.type: inlinewith noinlineblock) is now rejected immediately by the API server with a clear error message, instead of failing later during controller reconciliation.Special notes for reviewers
OIDCConfigRef.kubernetesuses a one-directional CEL rule (type != 'kubernetes' ? !has(self.kubernetes) : true) because thekubernetessub-field is optional even whentype == "kubernetes"— it has sensible defaults.configMapandinlinefields use the strict bidirectional pattern (type == 'X' ? has(self.X) : !has(self.X)) matchingMCPExternalAuthConfigSpec.Test plan
task lintpasses (operator code)task operator-test-integration— all 7 suites pass, including 14 new CEL validation testsGenerated with Claude Code