Skip to content

Report unsupported external auth types - #6242

Merged
ChrisJBurns merged 5 commits into
stacklok:mainfrom
3nesdeniz:agent/report-unsupported-external-auth
Nov 26, 2026
Merged

ChrisJBurns merged 5 commits into
stacklok:mainfrom
3nesdeniz:agent/report-unsupported-external-auth

Conversation

@3nesdeniz

@3nesdeniz 3nesdeniz commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MCPExternalAuthConfig has nine spec.type values, but each consumer kind implements only a subset, and the unsupported combinations fail silently: the resource reads as valid, the workload runs, and the credential is never injected. This PR delivers the two things #5930 asks for:

  • Reconcile-time validation surfaced as status conditions. An unsupported consumer/type combination sets ExternalAuthConfigValidated=False with reason UnsupportedAuthType on MCPServer and MCPServerEntry, and a per-backend condition on VirtualMCPServer (including the discovered-mode case where a bearerToken-backed MCPRemoteProxy used to vanish from aggregation with only a log line). These are terminal configuration errors and return without requeueing; the existing watches trigger reconciliation when the spec or the referenced config changes.
  • Supported consumer kinds documented in the CRD. Field godoc on MCPExternalAuthConfigSpec.Type and on every consumer's externalAuthConfigRef, flowing into the generated CRD schemas and reference docs.

The support matrix lives in cmd/thv-operator/pkg/externalauthsupport and cannot drift from the code: the VirtualMCPServer/MCPServerEntry rows derive from the converter registry (converters.DefaultRegistry().RegisteredTypes()), and the MCPServer/MCPRemoteProxy rows are enforced at the run-config dispatch — AddExternalAuthConfigOptions now takes the consumer and returns a typed UnsupportedTypeError for a type outside the consumer's row. TestAddExternalAuthConfigOptions_EnforcesSupportMatrix drives the real dispatch with all nine types for both consumers and requires agreement with the matrix in both directions.

headerInjection, upstreamInject, and xaa stay accepted on MCPServer and MCPRemoteProxy, and now say what they are. The proxy runner does nothing with them, but discovered mode reads the reference from the backend resource and the VirtualMCPServer applies it when it calls that backend. Rejecting them on the backend would take the backend, and discovered mode with it, down (the VirtualMCP e2e suites cover exactly this). So the condition stays ExternalAuthConfigValidated=True, but with reason AppliedByVirtualMCPServer and a message saying the backend does not apply the type itself and it takes effect only when a VirtualMCPServer discovers the backend. A standalone MCPServer with a headerInjection config, the case #5930 singles out, no longer reads as plainly valid. MCPServer still rejects bearerToken and awsSts; MCPRemoteProxy has no type left to reject.

On VirtualMCPServer the published config does not change. The converter still resolves every entry declared in spec.outgoingAuth (default and backends) and fails as a whole when one cannot be resolved, so no config is written with the entry missing and no backend falls back to another credential or to no auth. What this PR adds is the reporting: the reconciler records which entry failed, and why. When every declared entry that failed has an unsupported type, the refusal is terminal: the resource reports Phase=Failed with Ready=False (reason UnsupportedAuthType) and is not requeued, the same way MCPServer treats it. Any other failure (a missing config, a source reporting Valid=False) keeps returning its error and is retried. Auth discovered from a backend's own externalAuthConfigRef keeps today's behaviour, with the more specific UnsupportedAuthType reason on its condition.

Closes #5930

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)

  • E2E tests (task test-e2e)

  • Linting (task lint-fix)

  • Manual testing (describe below)

  • Unit: go test -race on everything under ./cmd/thv-operator/... except test-integration, plus ./pkg/vmcp/auth/converters/... and ./pkg/vmcp/config/....

  • Integration (envtest 1.31.0, run locally): mcp-external-auth, mcp-remote-proxy, mcp-server and virtualmcp suites.

  • Linting: go build, go vet, gofmt and gocyclo (limit 15) on the touched trees. golangci-lint v2.15.0 was run on the earlier pushes; for the latest push I rely on CI for it.

  • E2E was not run locally; it runs in CI.

  • Generated CRDs, Helm CRD templates and docs/operator/crd-api.md were regenerated when the API godoc changed. The latest push adds a condition reason constant only, so nothing is regenerated by it.

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

No field, type or CRD schema changes shape. The schema diff is godoc only. Two condition reasons are new: UnsupportedAuthType and AppliedByVirtualMCPServer.

Does this introduce a user-facing change?

Yes. What an operator can observe, before and after:

  • MCPServer referencing a bearerToken or awsSts config. Before: ExternalAuthConfigValidated=True. After: ExternalAuthConfigValidated=False / UnsupportedAuthType, Phase=Failed. The existing Deployment keeps running but no longer receives updates until the reference is fixed. On main this combination is not inert: for bearerToken the proxy runner crash-loops with secrets provider not configured. So for existing users the change turns a crash loop into a clear condition, not a working server into a failed one.
  • MCPServer or MCPRemoteProxy referencing a headerInjection, upstreamInject or xaa config. Before: ExternalAuthConfigValidated=True / ExternalAuthConfigValid, message MCPExternalAuthConfig '<name>' is valid. After: still True, but reason AppliedByVirtualMCPServer, and the message says the backend does not apply the type itself and it takes effect only when a VirtualMCPServer discovers the backend. The workload is unaffected. Anything matching on the old reason for these three types will change.
  • MCPServerEntry referencing an unsupported type, or a config whose own status is Valid=False. Before: Phase=Valid. After: Phase=Failed. The vMCP now skips the entry.
  • VirtualMCPServer, per-backend condition reason. Before: ConversionFailed. After: UnsupportedAuthType for unsupported types. Anything alerting on the old reason will change.
  • VirtualMCPServer whose declared spec.outgoingAuth entry (default or backends) has an unsupported type. Before: the config build failed with a plain error and was retried with backoff indefinitely; a resource that was already serving kept Phase=Ready, Ready=True and AuthConfigured=True at the new observedGeneration. After: the published config is still left untouched, and the resource reports Phase=Failed and Ready=False / UnsupportedAuthType, with a message naming the entries, and is not requeued. It heals on the next change to the spec or to the referenced MCPExternalAuthConfig.

Special notes for reviewers

  • A reported SpecValidationError now ends the VirtualMCPServer reconcile (a2e4bf7). Before, Reconcile went on to the pod-based status pass, which overwrote the Failed phase with the state of the pods still running the previous config. This also applies to the three SpecValidationError paths that were already in ensureVmcpConfigConfigMap (invalid delegate clients, invalid incoming OIDC file paths, invalid auth server integration): their Phase=Failed now persists as well.
  • Terminal only when every declared failure is UnsupportedAuthType. A declared entry that fails for another reason next to an unsupported one keeps the plain error and the retries, so a missing config that appears later is still picked up. The config-build tests cover that mixed case.
  • The advisory reason is shared. ConditionReasonAppliedByVirtualMCPServer sits next to ConditionReasonUnsupportedAuthType in conditions.go and is used by both MCPServer and MCPRemoteProxy through one helper, externalAuthValidCondition.

Out of scope, split out per review

Generated with Claude Code

@3nesdeniz

Copy link
Copy Markdown
Contributor Author

Hi @jhrozek — no rush at all, just flagging that this is ready for review whenever you have time. Happy to adjust anything about the approach.

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for digging into #5930 — the compatibility matrix itself is right. I checked every cell against the code rather than against the docs: the VirtualMCPServer and MCPServerEntry rows match the converter registry in pkg/vmcp/auth/converters/interface.go exactly, and the MCPServer/MCPRemoteProxy rows line up with the dispatcher switch in controllerutil/tokenexchange.go, including the non-obvious awsSts-on-MCPServer case, which fails on the empty-RemoteURL check in pkg/runner/middleware.go rather than silently no-opping. I also traced the reconcile flow to confirm it returns before the Deployment block, so this does close the unauthenticated-deploy footgun rather than just annotating it.

My main concern is scope. The issue asked for two things: reconcile-time validation surfaced as status conditions, and the supported consumer kinds documented in the field godoc. Both are here. But a lot came along with them, and some of it changes behaviour nobody asked to change.

The one I'd push back on hardest is the outgoing-auth precedence change in pkg/vmcp/aggregator/discoverer.go. In discovered mode an explicit per-backend override now wins over auth discovered from the backend resource, where previously discovered auth won. That decides which credential a live backend authenticates with. It may well be the right call, but it needs its own issue and its own discussion — it shouldn't be settled as a side effect of a PR about reporting unsupported types. Same goes for ExplicitBackends and its nil-versus-empty compatibility semantics, which exist only to support that change.

ExcludedBackends and DefaultAuthFailed are closer to the mark but still past the ask. The issue's vMCP line is "surface the skipped backend in VirtualMCPServer status rather than log-and-drop", which is a status condition. What's here is a fail-closed routing rework threaded through the discoverer, the watcher and the static path. I'd keep the condition and leave routing semantics for a separate change.

The examples fix (snake_case to camelCase under examples/operator/external-auth/) is a real bug and a good catch, but it's unrelated — worth its own PR so it can land quickly on its own merits.

Two things I'd treat as blocking regardless of what happens to the scope:

ensureVmcpConfigConfigMap now deep-copies the VirtualMCPServer, sets Spec.OutgoingAuth to nil, runs converter.Convert against that, then patches Source back on afterwards. That line is the only caller of Convert in the tree, so Converter.convertOutgoingAuth and convertBackendAuthConfig are now unreachable in production — they survive only in their own unit tests, which will keep passing while covering code that no longer runs. The controller already had a near-duplicate in convertBackendAuthConfigToVMCP, and this PR updates that copy to match the converter's behaviour. Better to pick one and delete the other than to disable the original by feeding it a modified input.

ExternalAuthConfigValidated on MCPServer has no path back to True. Both False branches are there (the new UnsupportedAuthType one and the pre-existing MultiUpstream one), plus RemoveStatusCondition when the ref goes away, but there's no success setter — MCPRemoteProxy has the matching block at the end of its handleExternalAuthConfig and MCPServer doesn't. Point a server at a two-upstream config, then edit that config down to one, and the condition stays False permanently. The MultiUpstream half predates this PR, but the new branch reproduces it in a function you're already editing.

Smaller things, several of which follow conventions already present in the files being changed:

  • excludedBackends and explicitBackends need +listType=atomic. That's what's failing the CRD Schema Compatibility check, and there's an existing +listType=atomic about 200 lines up in pkg/vmcp/config/config.go. The other red checks aren't yours: the E2E lifecycle jobs all died on a Docker Hub 502 pulling python:3.9-slim, and the unit-test failure is a flaky transparent-proxy test unrelated to this change.
  • pkg/vmcp/backendregistry/registry.go:130 still calls NewBackendWatcher without the auth config, and the comment directly above it asks that it stay in sync with cli/serve.go. It's only reachable from internal/exampleembedder today, but NewKubernetesBackendRegistry is the exported constructor for embedders and now has no way to pass an OutgoingAuthConfig at all.
  • The "failed default means deny" rule is implemented three times: ResolveForBackend, dependsOnFailedDefault in the discoverer, and again inline in backend_reconciler.go. They agree today, nothing keeps them agreeing, and drift reopens the hole this is meant to close. Same for outgoingAuthExclusionSet, copy-pasted verbatim into two packages — it'd be better as a method on OutgoingAuthConfig.
  • support_test.go re-declares supportMatrix as a literal and asserts Supports() matches it, so it can only fail on a typo made differently twice. The test that would earn its place asserts the vMCP rows equal the key set of converters.DefaultRegistry() and the MCPServer/MCPRemoteProxy rows equal the non-no-op arms of the dispatcher switch. That one breaks when someone adds a converter and forgets the table, which is the failure this package exists to prevent.
  • Three new ...WithAuthConfig constructors for two production callers of the old ones. Changing the signatures is smaller.
  • MCPRemoteProxy sets Ready=False with Reason: DeploymentNotReady for an external-auth configuration error.

One structural thought worth weighing before the next revision. The silent no-ops in AddExternalAuthConfigOptions are the actual subject of #5930 and they're still there — headerInjection, upstreamInject and xaa all still return nil. The support matrix is a second, hand-maintained source of truth sitting beside them, with nothing enforcing agreement. Making those arms return the UnsupportedTypeError directly would put the guard at the choke point every consumer already routes through, and the MCPServer/MCPRemoteProxy rows could then derive from the switch instead of restating it.

@3nesdeniz

3nesdeniz commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @jhrozek — checking the matrix cell-by-cell against the code is exactly what this needed, and you were right about the scope. Reworked accordingly; the diff against main went from ~+3,300 to +1,620/−380, and every runtime behaviour change is gone.

Scope

The two blockers

  • Convert no longer gets a modified copy: the converter's outgoing-auth path (convertOutgoingAuthWithDefaults/convertOutgoingAuth/convertBackendAuthConfig) is deleted, and processOutgoingAuth — already the status-aware authority — is the only implementation left. Discovered mode persists exactly what the spec declares, as before. The one deliberate behaviour change is in scope: a single broken backend in inline mode now degrades to a per-backend condition instead of failing the whole conversion.
  • MCPServer's handleExternalAuthConfig got the missing success setter, mirroring MCPRemoteProxy — your two-upstreams-then-one scenario now flips the condition back to True, with a regression test.

Structural suggestion — taken. AddExternalAuthConfigOptions takes the consumer and enforces the matrix at the top; the silent no-op arms are gone (they remain as explicit unreachable cases for switch exhaustiveness, failing loudly if the matrix ever admits one without a real arm). The vMCP/MCPServerEntry rows derive from converters.DefaultRegistry(), so registering a converter extends them automatically. The tautological test is replaced by TestAddExternalAuthConfigOptions_EnforcesSupportMatrix, which drives the real dispatch with all nine types for both consumers and requires agreement with the matrix in both directions.

Smaller items. +listType=atomic is moot — the fields no longer exist and the regenerated CRDs dropped them, which should clear the schema-compatibility check. The NewBackendWatcher gap, the triplicated failed-default rule, the copy-pasted exclusion set, and the three ...WithAuthConfig constructors all went away with the revert. MCPRemoteProxy now reports Ready=False with AuthInvalid instead of DeploymentNotReady.

Validation: build and golangci-lint clean, unit suites green, and the full test-integration suite green under envtest (including mcp-remote-proxy and virtualmcp). Rebased on current main.

@Sanskarzz
Sanskarzz self-requested a review September 28, 2026 20:07
@Sanskarzz

Copy link
Copy Markdown
Collaborator

@3nesdeniz Thanks for narrowing the PR after Jakub’s review. I found a change in failure behavior that I think we should resolve before merging. When an explicitly configured outgoingAuth.default fails conversion, the operator records a condition but publishes a config with no default. A backend depending on it can then run unauthenticated. In discovered mode, a failed explicit per-backend entry is omitted, and backend exclusion applies only in inline mode, so requests may fall back to another credential or no auth. The previous converter failed conversion in these cases.

Could you preserve the protection against that fallback while surfacing the status condition, and add a test of the resulting config or routing behavior? The PR also currently has merge conflicts; please resolve those against the latest main when updating the branch.

@3nesdeniz
3nesdeniz force-pushed the agent/report-unsupported-external-auth branch from 57eb59b to c61237c Compare November 14, 2026 23:08
@3nesdeniz

Copy link
Copy Markdown
Contributor Author

@Sanskarzz thanks, you were right. Removing the converter's outgoing-auth path is what let a config be published without the failed entry.

What changed in this push:

  • The protection is back. The converter resolves spec.outgoingAuth exactly as on main again, so an unresolved default or declared backend still fails the conversion and nothing is published. This PR no longer touches converter.go.
  • The condition is still surfaced. Before returning that error, the reconciler records the per-entry condition (DefaultAuthConfig / BackendAuthConfig-<name>), so the reason shows up in status.
  • Tests of the resulting config. TestEnsureVmcpConfigConfigMap_UnresolvedDeclaredOutgoingAuth (no ConfigMap is written, in both modes), …KeepsPublishedConfig (an already published ConfigMap is left untouched), and TestVirtualMCPServerReconcile_UnresolvedDeclaredOutgoingAuthIsReported (the condition reaches the stored status).
  • Rebased on main. main now has its own success setter for MCPServer and markConfigHandlerFailed for MCPRemoteProxy, so I dropped my versions of both. I also added UnsupportedAuthType to ownedByLocalValidation; without it the mirror removes and re-adds that condition on every reconcile.

Merging the converter's and the reconciler's conversion into one path changes which failures are fatal, so I left it out of this PR.

Locally, the operator unit tests with -race, the mcp-external-auth, mcp-remote-proxy, mcp-server and virtualmcp envtest suites and golangci-lint v2.15.0 all pass.

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.98995% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.33%. Comparing base (619c160) to head (1b3172e).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...d/thv-operator/controllers/mcpserver_controller.go 95.00% 2 Missing ⚠️
...d/thv-operator/controllers/external_auth_mirror.go 93.75% 1 Missing ⚠️
...d/thv-operator/pkg/controllerutil/tokenexchange.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6242      +/-   ##
==========================================
+ Coverage   82.15%   82.33%   +0.17%     
==========================================
  Files         932      936       +4     
  Lines       94529    95434     +905     
==========================================
+ Hits        77659    78572     +913     
+ Misses      16865    16857       -8     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 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.

MCPExternalAuthConfig has nine types, but each consumer kind implements
only a subset, and some unsupported combinations failed silently: the
resource read as valid, the workload ran, and the credential was never
injected (stacklok#5930).

Validate the consumer/type combination at reconcile time and surface
failures as ExternalAuthConfigValidated=False with reason
UnsupportedAuthType on MCPServer and MCPServerEntry, and as per-entry
conditions on VirtualMCPServer. On MCPServer and MCPServerEntry these
terminal configuration errors return without requeueing; the watches on
the spec and the referenced config trigger reconciliation when either
changes. Document each consumer's supported types in the field godoc so
the CRD schemas and reference docs carry them.

The support matrix lives in one place and cannot drift from the code:
the vMCP-backed rows derive from the converter registry, and the
MCPServer/MCPRemoteProxy rows are enforced at the run-config dispatch in
AddExternalAuthConfigOptions, which now takes the consumer and returns a
typed UnsupportedTypeError for a type outside the consumer's row. A test
drives that dispatch with every type for both consumers and requires
agreement with the matrix in both directions.

headerInjection, upstreamInject, and xaa stay accepted on MCPServer and
MCPRemoteProxy. The proxy runner does nothing with them, but discovered
mode reads the reference from the backend resource and the
VirtualMCPServer applies it when it calls that backend, so rejecting
them on the backend would take the backend, and discovered mode with
it, down. The field godoc now says who applies them.

On VirtualMCPServer the published config does not change. The converter
still resolves every entry declared in spec.outgoingAuth and fails as a
whole when one cannot be resolved, so no config is written with the
entry missing and no backend falls back to another credential or to no
auth. The reconciler now records which entry failed, and why, before
returning that error, so the refusal is explained in status and not
only in the operator log.

The unsupported-type condition is owned by local validation, like the
CA bundle and run-config failures, so the mirror's clear branch leaves
it in place instead of removing and re-adding it on every reconcile.

Closes stacklok#5930.

Signed-off-by: Enes Deniz <[email protected]>
@3nesdeniz
3nesdeniz force-pushed the agent/report-unsupported-external-auth branch from c61237c to 5da3fb9 Compare November 14, 2026 23:37
@3nesdeniz

Copy link
Copy Markdown
Contributor Author

One more change after CI. The E2E Test Lifecycle jobs failed on my first push, and the cause was this PR, not infra.

Discovered mode reads the auth reference from the backend resource. The VirtualMCP e2e suites rely on that: an MCPServer backend references a headerInjection config (and an upstreamInject one in the Redis session suite), and the VirtualMCPServer applies it. This PR rejected those types on MCPServer and MCPRemoteProxy, so the backend went to Failed and never became ready.

So headerInjection, upstreamInject, and xaa are accepted on MCPServer and MCPRemoteProxy again, as on main: the proxy runner adds nothing for them and the backend reconciles normally. The matrix keeps them as a separate named set (vmcpAppliedTypes), the dispatch test requires them to be a no-op, and the field godoc now says a VirtualMCPServer applies them. MCPServer still rejects bearerToken and awsSts with UnsupportedAuthType. MCPRemoteProxy has no type left to reject, so its controller is back to what is on main.

That leaves one cell of #5930 answered by documentation instead of a condition: a standalone MCPServer or MCPRemoteProxy with headerInjection still reads as valid. I can add an advisory condition for that case if you want one, but it should not fail the backend.

ChrisJBurns and others added 2 commits November 26, 2026 09:41
Resolve conflicts with the OSS Entra OBO port (stacklok#7201) and the external
auth mirror rework (stacklok#7162):

- Keep the UnsupportedAuthType check alongside main's OBO incoming-auth
  check in MCPServer, and treat UnsupportedAuthType as a local-validation
  reason in isLocalValidationFailure.
- Route the MCPServer terminal-error path through main's
  markExternalAuthConfigFailed, keeping the PR's skip of unchanged status
  writes.
- Drop "obo when an enterprise handler is registered" wording and the
  deprecated EnterpriseRequired reason from the PR's godoc and tests; obo
  is now built in.
- Move the support-matrix dispatch test into a fresh tokenexchange_test.go
  (main deleted the old file) and pass the consumer in main's OBO tests.
- Regenerate CRD manifests and API docs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Chris Burns <[email protected]>
Merging main added the obo incoming-auth check next to the
unsupported-type check in handleExternalAuthConfig, pushing its
cyclomatic complexity past the gocyclo limit. Move both consumer checks
into validateMCPServerExternalAuthConsumer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Chris Burns <[email protected]>
@ChrisJBurns

Copy link
Copy Markdown
Collaborator

/retest

ChrisJBurns
ChrisJBurns previously approved these changes Nov 26, 2026
@rdimitrov

rdimitrov commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Thanks for sticking with this through three rounds. The scope is right now, and both earlier blockers (the unreachable converter path and the missing success setter) plus the fail-closed concern on declared outgoing auth are resolved.

I checked the head against #5930, ran task operator-test (green), and did an upgrade test on a kind cluster: deployed main, created the combinations an existing user could have, then upgraded the CRDs and operator to this branch.

What I saw work

  • MCPServer + bearerToken: ExternalAuthConfigValidated=False / UnsupportedAuthType, Phase=Failed. It heals with no requeue both when the ref is repointed and when the referenced MCPExternalAuthConfig is edited in place, and goes back to UnsupportedAuthType when the config is flipped back.
  • MCPServerEntry + bearerToken: Phase=Failed with UnsupportedAuthType, heals the same way.
  • VirtualMCPServer: per-backend conditions carry UnsupportedAuthType. An unsupported declared default leaves the published ConfigMap untouched (resourceVersion unchanged), as described.
  • MCPServer and MCPServerEntry resourceVersions stay put at steady state, so the DeepEqual guards do their job. MCPRemoteProxy behaves as on main.

One thing worth adding to the description: on main, MCPServer + bearerToken is not inert. The proxy runner crash-loops with secrets provider not configured. So for existing users this change turns a crash loop into a clear condition, not a working server into a failed one.

1. The headerInjection footgun from #5930 still reads as valid

The issue singles out headerInjection on MCPServer/MCPRemoteProxy as the security-adjacent case. Keeping these types accepted is right, since rejecting them takes discovered mode down. But a standalone MCPServer referencing a headerInjection config still reports ExternalAuthConfigValidated=True with MCPExternalAuthConfig 'hdr' is valid, and only the field godoc says otherwise.

A non-failing advisory condition would close this without hurting discovered mode: keep ExternalAuthConfigValidated=True, but with a distinct reason and a message saying the proxy does not apply this type and it takes effect only when a VirtualMCPServer discovers the backend. externalauthsupport.AppliedByVirtualMCPServer() already exists for exactly this and is currently only called from tests. I'd take this in this PR, since it is the cell of #5930 the issue calls out. A follow-up linked from the description would also work.

2. An inline VirtualMCPServer stays Ready after its new outgoing auth is refused

I changed an inline-mode VirtualMCPServer's spec.outgoingAuth.default from an unauthenticated config to a bearerToken one. The ConfigMap was correctly left alone and DefaultAuthConfig=False / UnsupportedAuthType appeared, but the resource also reported:

generation: 2, observedGeneration: 2
phase: Ready
Ready=True [AllBackendsRoutable]
AuthConfigured=True [AuthValid]

So it reads as having applied generation 2 while it serves generation 1's auth, which is the "looks configured, isn't" pattern #5930 is about. The reconcile also returns a plain error, so it requeues with backoff forever (17 reconcile errors in the first 3 minutes) even though nothing heals until the spec changes.

The Ready/observedGeneration part predates this PR. But this PR is where the operator first knows the refusal is a terminal UnsupportedTypeError, and it already treats the same case as terminal on MCPServer. Returning a SpecValidationError (or setting Phase=Failed / a False top-level condition) when every declared-entry failure is UnsupportedAuthType would make the two consistent. If you'd rather keep that out of scope, please say so in the description.

3. PR description

Per .claude/rules/pr-creation.md it needs the Type of change and Test plan sections, plus a user-facing change section with before/after for what an operator can observe:

  • MCPServer referencing bearerToken or awsSts: ExternalAuthConfigValidated=True → False / UnsupportedAuthType, Phase=Failed. The existing Deployment keeps running but no longer receives updates until the reference is fixed.
  • MCPServerEntry referencing an unsupported type, or a config whose own status is Valid=False: Phase=Valid → Failed. The vMCP now skips the entry.
  • VirtualMCPServer per-backend condition reason: ConversionFailed → UnsupportedAuthType for unsupported types. Anything alerting on the old reason will change.

It should also reference #5930 (Closes if you take item 1, otherwise Part of).

When an entry declared in spec.outgoingAuth referenced an auth type
VirtualMCPServer does not support, the operator kept the previous
ConfigMap but still reported Phase=Ready with observedGeneration
advanced, and requeued with backoff forever although only a spec or
referenced-config change can heal it.

Treat a conversion failure as a SpecValidationError when every failed
declared entry is an UnsupportedTypeError: Phase=Failed, Ready=False /
UnsupportedAuthType, no requeue. Other failures still return the error
and retry.

reconcileResources now ends the reconcile on a SpecValidationError.
Before, the pod-based status pass ran afterwards and overwrote the
Failed phase, which also affected the existing delegate-client, OIDC
file path and auth server integration validation errors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Chris Burns <[email protected]>
@ChrisJBurns

Copy link
Copy Markdown
Collaborator

/retest

ChrisJBurns
ChrisJBurns previously approved these changes Nov 26, 2026
MCPServer and MCPRemoteProxy accept headerInjection, upstreamInject and
xaa so that a VirtualMCPServer can discover the reference on the backend
and apply it. The proxy runner itself does nothing with them, but the
backend reported ExternalAuthConfigValidated=True with "is valid", so a
backend used on its own read as protected by a config that is never
applied. That is the headerInjection case stacklok#5930 singles out.

Keep the condition True, since failing it would take discovered mode
down, but give it the reason AppliedByVirtualMCPServer and a message
saying the backend does not apply the type itself and it takes effect
only when a VirtualMCPServer discovers the backend. Both controllers use
one helper built on externalauthsupport.AppliedByVirtualMCPServer.

Signed-off-by: Enes Deniz <[email protected]>
@3nesdeniz

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review and for running the upgrade test, @rdimitrov, and thanks @ChrisJBurns for taking item 2 in a2e4bf7. Status of the three points:

1. headerInjection on a standalone backend. Done in the commit I just pushed. MCPServer and MCPRemoteProxy keep ExternalAuthConfigValidated=True for headerInjection, upstreamInject and xaa, but now with reason AppliedByVirtualMCPServer and a message saying the backend does not apply the type itself and it takes effect only when a VirtualMCPServer discovers the backend. Both controllers use one helper built on externalauthsupport.AppliedByVirtualMCPServer(). The condition goes back to the plain "valid" reason when the config is repointed to a type the proxy runner applies. One envtest assertion in the mcp-remote-proxy suite expected the old reason for a headerInjection config and is updated.

2. VirtualMCPServer staying Ready after a refused outgoing auth. Covered by a2e4bf7. I had reached the same change locally, including ending the reconcile on a SpecValidationError so the pod-based status pass does not overwrite Failed, so I dropped mine and built on that commit.

3. PR description. Rewritten to the template: Type of change, Test plan, API compatibility, and a user-facing section with before/after for each case, including your note that MCPServer + bearerToken crash-loops on main. It now says Closes #5930.

Tests on the pushed head: operator unit suites with -race, and the mcp-external-auth, mcp-remote-proxy, mcp-server and virtualmcp envtest suites, run locally. I did not run golangci-lint or the e2e suites locally.

@ChrisJBurns
ChrisJBurns merged commit 16554dc into stacklok:main Nov 26, 2026
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consumers silently ignore unsupported MCPExternalAuthConfig types

5 participants