# AttributeGrantReferenceNotFound

An OIDCClient or Group that an Organization's spec.attributeWriteGrants names is missing, not registered on the server yet, or of another organization; that grant is not held, the rest of the resource is written, and the resource is Pending.

## Meaning

The operator sends each grant's client as the `status.clientId` of the `OIDCClient` it
names, and each group as the `status.groupId` of the `Group`. One of them does not exist,
has no id yet because the server has not registered it, or its `status.organization` is
not this organization. A grant whose reference does not resolve is left out of what is
sent, so the server holds no grant for a client or group the resource does not name, and
one the server held before is revoked. Every other grant and setting of the resource is
written as usual, so one dangling reference never holds back a revocation or a policy
change. A new organization reports it until its clients are registered, since a grant can
only name a client the organization already holds.

## Impact

The service attribute API refuses the client of each such grant, as it does every client
without a grant, until the condition clears. Normal for the moment between creating an
Organization and its clients; a fault when it stays.

## Diagnosis

1. `kubectl describe organization <name>` names the grant, the kind, the reference and
   which of the three it is.
2. `kubectl -n <ns> get oidcclient <client> -o jsonpath='{.status}'` or
   `kubectl -n <ns> get group <group> -o jsonpath='{.status}'`: no id means that resource
   is not Ready, and its own condition says why.
3. Compare its `status.organization` with the Organization's `spec.slug`.

## Mitigation

- Create the OIDCClient or Group, or fix the reference in `spec.attributeWriteGrants`.
- One that is not Ready: fix what its condition reports.
- One of another organization: declare it in a namespace this organization admits.
- The server refuses a public client and an attribute not declared with
  `applicationWrite`, which the resource then reports as Refused.

## Escalation

If every reference is Ready in this organization and the condition stays, open an issue
with the operator's version, the server's version and the condition message.

---

[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.
