komiti: creating a komiti before files is deployed 400s on the claim-map 404 — and the retry silently "succeeds" leaving the komiti permanently unmapped #1407

Closed
opened 2026-09-12 04:04:43 +00:00 by ben · 1 comment
Owner

Symptom

Creating a komiti on a community that has no files service deployed yet fails:

POST /api/v1/komiti e2e-portal-crew
400 {"code":"act_failed","message":"kanidm: add files komiti claim-map \"e2e-portal-crew\": unexpected status 404"}

Found by the #1373 Portal member-journey drive (20260912T034016Z on elitebook, leg portal-s1e, 17.2m in). The leg creates a komiti before co-hosting files — deliberately, because PT-S1e is the honest empty home and needs a member with nothing open to them.

Cause

internal/member/komiti.go CreateKomiti writes the files claim-map unconditionally:

created, err := o.komitiReg.CreateKomiti(ctx, name)   // the kanidm GROUP is created HERE
if err != nil { return err }
if !created { return nil }                            // idempotent — and see below
if err := o.filesClaimMap.AddFilesKomitiClaimMap(ctx, name); err != nil {
    return err                                        // 404 when files isn't deployed
}

AddFilesKomitiClaimMap (internal/kanidm/kanidm.go:511) writes to the claim-map path of the OAuth2 client nextcloud. That client is created by the files render (internal/clan/files.go). With files not deployed the client does not exist, kanidm answers 404, and the whole call fails.

The worse half — a retry "succeeds" and leaves the komiti permanently broken

The group is created before the claim-map write, and the create is idempotent. So:

  1. First call: group created in kanidm, claim-map 404s, API returns 400. Operator sees a failure.
  2. Operator retries: CreateKomiti returns created=false → return nil → API returns success. AddFilesKomitiClaimMap is never reached.

The komiti now exists, reports created, and has no ocgroups claim-map entry — so when files is later deployed, members of that komiti silently do not get files access, and nothing in the system says why. The failure is invisible from that point on.

Why it has not been seen before

Every existing journey creates komiti after a deploy (invite-member runs post-deploy), so the pre-deploy order was never exercised. It is a perfectly ordinary operator order though: set up your groups, then deploy your services.

Suggested shape (not a ruling)

  • Write the claim-map only when the files OAuth2 client exists, and treat its absence as "nothing to map yet" rather than an error.
  • Make the files render backfill claim-maps for komiti that already exist when files is deployed — otherwise every komiti made before the deploy stays unmapped.
  • Either way, close the retry hole: the idempotent early return must not skip the claim-map write. Reconciling on every call is safer than branching on created.

Repro

On a founded community with no files service: POST /api/v1/komiti {"name":"anything"} → 400. Then repeat the same POST → 200, and the komiti has no claim-map entry.

Evidence: test-results/drive-droplet/20260912T034016Z on elitebook-distributed-server-03; drive log /home/swarm/swarm/drive-logs/portal-1373-hand-20260912T034008Z.log.

## Symptom Creating a komiti on a community that has **no files service deployed yet** fails: ``` POST /api/v1/komiti e2e-portal-crew 400 {"code":"act_failed","message":"kanidm: add files komiti claim-map \"e2e-portal-crew\": unexpected status 404"} ``` Found by the #1373 Portal member-journey drive (`20260912T034016Z` on elitebook, leg `portal-s1e`, 17.2m in). The leg creates a komiti **before** co-hosting files — deliberately, because PT-S1e is the honest empty home and needs a member with nothing open to them. ## Cause `internal/member/komiti.go` `CreateKomiti` writes the files claim-map unconditionally: ```go created, err := o.komitiReg.CreateKomiti(ctx, name) // the kanidm GROUP is created HERE if err != nil { return err } if !created { return nil } // idempotent — and see below if err := o.filesClaimMap.AddFilesKomitiClaimMap(ctx, name); err != nil { return err // 404 when files isn't deployed } ``` `AddFilesKomitiClaimMap` (`internal/kanidm/kanidm.go:511`) writes to the claim-map path of the OAuth2 client `nextcloud`. That client is created by the **files render** (`internal/clan/files.go`). With files not deployed the client does not exist, kanidm answers **404**, and the whole call fails. ## The worse half — a retry "succeeds" and leaves the komiti permanently broken The group is created **before** the claim-map write, and the create is idempotent. So: 1. First call: group created in kanidm, claim-map 404s, API returns 400. Operator sees a failure. 2. Operator retries: `CreateKomiti` returns `created=false` → **`return nil`** → API returns success. **`AddFilesKomitiClaimMap` is never reached.** The komiti now exists, reports created, and has **no ocgroups claim-map entry** — so when files *is* later deployed, members of that komiti silently do not get files access, and nothing in the system says why. The failure is invisible from that point on. ## Why it has not been seen before Every existing journey creates komiti **after** a deploy (`invite-member` runs post-deploy), so the pre-deploy order was never exercised. It is a perfectly ordinary operator order though: set up your groups, then deploy your services. ## Suggested shape (not a ruling) - Write the claim-map **only when the files OAuth2 client exists**, and treat its absence as "nothing to map yet" rather than an error. - Make the files render **backfill** claim-maps for komiti that already exist when files is deployed — otherwise every komiti made before the deploy stays unmapped. - Either way, close the retry hole: the idempotent early return must not skip the claim-map write. Reconciling on every call is safer than branching on `created`. ## Repro On a founded community with no files service: `POST /api/v1/komiti {"name":"anything"}` → 400. Then repeat the same POST → 200, and the komiti has no claim-map entry. Evidence: `test-results/drive-droplet/20260912T034016Z` on `elitebook-distributed-server-03`; drive log `/home/swarm/swarm/drive-logs/portal-1373-hand-20260912T034008Z.log`.
Author
Owner

Duplicate of #1406 — closing this one. #1406 was filed at 04:03Z, four minutes before this, on the same drive (20260912T034016Z), and is the better ticket: it carries the live kanidm journal showing the exact POST /v1/oauth2/nextcloud/_claimmap/... 404 and the no candidates match filter error, confirms three ways that no files OAuth2 client exists on the box, and already names the same three remedies including reconciling claim-maps on deploy. It also covers the non-atomic create and the !created early return that hides the gap on retry.

Nothing here is additive. #1373 is blocked on #1406, which is where the work is.

For the record, the drive that surfaced it was launched by hand from elitebook-distributed-server-03 at 03:40Z after clearing four separate blockers (the slug collision #1401, the wildcard claimability guard d64e3ac5, a session waiter whose process check matched its own command line, and a payload refresh that writes to a different directory than the drive reads). It reached 19 legs, 18 green, and this was the only red.

**Duplicate of #1406 — closing this one.** #1406 was filed at 04:03Z, four minutes before this, on the same drive (`20260912T034016Z`), and is the better ticket: it carries the live kanidm journal showing the exact `POST /v1/oauth2/nextcloud/_claimmap/...` 404 and the `no candidates match filter` error, confirms three ways that no files OAuth2 client exists on the box, and already names the same three remedies including reconciling claim-maps on deploy. It also covers the non-atomic create and the `!created` early return that hides the gap on retry. Nothing here is additive. #1373 is blocked on #1406, which is where the work is. For the record, the drive that surfaced it was launched by hand from `elitebook-distributed-server-03` at 03:40Z after clearing four separate blockers (the slug collision #1401, the wildcard claimability guard `d64e3ac5`, a session waiter whose process check matched its own command line, and a payload refresh that writes to a different directory than the drive reads). It reached 19 legs, 18 green, and this was the only red.
ben closed this issue 2026-09-12 04:12:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1407
No description provided.