# IntrospectionClientNotFound

The OIDCClient a ProtectedResource's spec.introspectionClient names is missing, not registered on the server yet, or of another organization; the resource is Ready=False, Error, and the API is registered with no introspection client.

## Meaning

The operator sends the API's introspection client as the client_id of the `OIDCClient`
`spec.introspectionClient` names, in the resource's own namespace, and reads it from that
client's `status.clientId`. The OIDCClient does not exist, has no `status.clientId` because
the server has not registered it yet, or its `status.organization` is not the resource's
organization. The API is registered with no introspection client meanwhile, clearing one
the server held, so a client that comes to hold the old client_id is never the API's; the
operator watches OIDCClients and sends the client once it is registered in the resource's
organization. The server holds the client it was sent by its registration, not its
client_id, so a client deleted and registered again is sent again. It refuses a client
that is not confidential, which the resource reports as Refused.

## Impact

The API is registered with its identifier, scopes and lifetime, but no client introspects
its tokens as the API until the condition clears: the API's client is answered
`active: false` for every token issued to another client, so an API that authorizes by
introspection refuses its callers. Normal for the moment between applying a
ProtectedResource and the OIDCClient it names; a fault when it stays.

## Diagnosis

1. `kubectl -n <ns> describe protectedresource <name>` names the OIDCClient and which of the
   three it is. The admin dashboard's Problems page shows the same message.
2. `kubectl -n <ns> get oidcclient <client> -o jsonpath='{.status}'`: no `clientId` means
   the OIDCClient itself is not Ready; its own condition says why.
3. Compare the OIDCClient's `status.organization` with the organization the resource's
   namespace configures.
4. The server's audit log: query `/v1/admin/orgs/<slug>/audit-events` with
   `action=oauth.token.introspected&client_id=<the API's client_id>`. Records refused with
   cause `grant_client_mismatch` and an `owner_client_id` are the API's introspections the
   server does not answer for it; see [Querying](https://www.nauthera.io/docs/v1/audit-log#querying).

## Mitigation

- Create the OIDCClient in the resource's namespace, or fix the name in
  `spec.introspectionClient`; leave the field out if the API does not introspect tokens.
- An OIDCClient that is not Ready: fix what its condition reports.
- An OIDCClient of another organization: declare the client in the resource's
  organization.
- Make the client confidential (a `tokenEndpointAuthMethod` other than `none`), or the
  server refuses the resource once the client is registered.

## Escalation

Escalate only if the OIDCClient is Ready in the resource's namespace and organization and
the condition stays; attach both resources' `kubectl describe` output and the operator
version.

---

[Operator failure reasons](https://www.nauthera.io/docs/v1/runbooks/operator) · Generated from [`operator/internal/runbook/conditions.yaml`](https://github.com/nauthera/nauthera-server/blob/main/operator/internal/runbook/conditions.yaml) in nauthera-server.
