fix(tenants): Setting the current status again is a no-op #75

Merged
sharang merged 1 commits from fix/status-unchanged-noop into main 2026-10-14 11:09:30 +00:00
Owner

On stage, staff picked "Apply" (set status) with trial selected on a trial tenant, instead of "Extend". The registry wrote an update, a tenant.status_changed audit entry (trial → trial) and a Keycloak sync. The audit log showed an entry, but nothing had changed.

Change: POST /v1/tenants/{id}/status with the tenant's current status answers 200 with the unchanged tenant: no write, no audit entry, no Keycloak sync. The call stays idempotent for scripts. Other transitions are unchanged.

Test: TestSetStatus_unchangedIsNoOp (memory and Postgres) checks 200 and that no audit entry is added. It fails without the fix ("audit entries: 1, want 0"). go vet and go test -short ./... pass locally; the full Postgres suite runs in CI.

Companion: the portal staff page greys out "Apply" until a different status is chosen (separate portal PR).

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

On stage, staff picked "Apply" (set status) with `trial` selected on a trial tenant, instead of "Extend". The registry wrote an update, a `tenant.status_changed` audit entry (`trial` → `trial`) and a Keycloak sync. The audit log showed an entry, but nothing had changed. **Change:** `POST /v1/tenants/{id}/status` with the tenant's current status answers 200 with the unchanged tenant: no write, no audit entry, no Keycloak sync. The call stays idempotent for scripts. Other transitions are unchanged. **Test:** `TestSetStatus_unchangedIsNoOp` (memory and Postgres) checks 200 and that no audit entry is added. It fails without the fix ("audit entries: 1, want 0"). `go vet` and `go test -short ./...` pass locally; the full Postgres suite runs in CI. Companion: the portal staff page greys out "Apply" until a different status is chosen (separate portal PR). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-10-14 10:29:09 +00:00
fix(tenants): Setting the current status again is a no-op
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 25m40s
ci / image (pull_request) Skipped
34783ec3e0
POST /v1/tenants/{id}/status with the status the tenant already has wrote
an update, a tenant.status_changed audit entry ("trial" → "trial") and a
Keycloak sync. Staff picking "Apply" instead of "Extend" on a trial then saw
an audit entry but no change. Now the call answers 200 with the unchanged
tenant and does nothing else, so repeating it stays harmless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit 310c438aea into main 2026-10-14 11:09:30 +00:00
sharang deleted branch fix/status-unchanged-noop 2026-10-14 11:09:30 +00:00
Sign in to join this conversation.