invite-member: suspend addresses Nextcloud by bare person id, user_oidc JIT'd the SPN #866

Closed
opened 2026-08-26 02:56:57 +00:00 by matou-build-agent · 2 comments

Failure

invite-member is the run's only red (artifacts/verdict.json: "firstRedLeg": "invite-member", 24 green / 1 red / 1 skip). This is not the known frontier — the frontier rows skip with the own-VPS carrier reason (backup-honest-floor, and alert-email / rescue-rung in the leg table), whereas invite-member is reachable: () => true and actually ran.

Suspend move 3 (the Nextcloud reconciler) fails:

POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: read user \"e2e-member\" failed: OCS 404 User does not exist"}

That message is literally true and badly misleading. There is no Nextcloud user e2e-member. There is one called e2e-member@id.rehearsal-b.idss.nz, and it was created six seconds before the suspend. The control plane looked up the wrong id.

Evidence — the live droplet (134.199.165.229, still up)

ssh was accepted; systemctl --failed is empty and every service is listening. The Nextcloud user list:

  - operator@id.rehearsal-b.idss.nz: Drive Operator
  - e2e-member@id.rehearsal-b.idss.nz: E2E Member
  - ocadmin: ocadmin
$ nextcloud-occ user:info e2e-member
user not found

$ nextcloud-occ user:info "e2e-member@id.rehearsal-b.idss.nz"
  - user_id: e2e-member@id.rehearsal-b.idss.nz
  - display_name: E2E Member
  - enabled: true
  - groups:
    - e2e-crew

The account exists, is enabled, carries the right display name and the e2e-crew komiti. Timing puts it inside the drive, before the suspend:

$ nextcloud-occ user:lastseen "e2e-member@id.rehearsal-b.idss.nz"
e2e-member@id.rehearsal-b.idss.nz's last login: 2026-08-26 02:46:45 UTC

and the suspend itself is in the journal at 02:46:51 — move 1 succeeded against kanidm using the bare id (logs/droplet-journal.txt, 02:46:51):

method: PUT | uri: /v1/person/e2e-member/_attr/account_expire | status_code: 200

So the same personID is valid on kanidm and invalid on Nextcloud. That is the whole bug.

The chain, in repo terms

  1. internal/clan/files.go:720-721 (and the droplet twin in internal/clan/files_idp_gateway.go) provisions user_oidc with the claim used verbatim as the Nextcloud uid:
    --unique-uid=0 \
    --mapping-uid=preferred_username \
    
  2. The kanidm nextcloud oauth2 client is created imperatively (files_idp_gateway.go:183-206, files.go:650-693) and never gets the short-username toggle, so kanidm emits preferred_username as the SPN name@domain. The gate client does set it — internal/clan/vmguest.go:1212: preferShortUsername = true; (STATUS.md:2137 documents it as part of the gate-oidc client). The files client drifted from that convention.
  3. Nextcloud therefore JIT-provisions uid e2e-member@id.rehearsal-b.idss.nz (proven above).
  4. The control plane stores the bare handle — internal/member/byhand.go:85: PersonID: spec.Username, — and internal/member/suspend.go:194 passes it straight through: return o.reconciler.DisableCredentials(personID).
  5. internal/nextcloud/nextcloud.go:264 GETs /ocs/v1.php/cloud/users/e2e-member → OCS 404.

Secondary defect — and a false-green trap

internal/nextcloud/nextcloud.go:351 tolerates only the historical missing-user code:

ocsOK       = 100
ocsNotFound = 998

Nextcloud 32.0.11 answers statuscode: 404 in the OCS envelope, so the deliberate "no account here — nothing to reconcile" path at nextcloud.go:239 never fired and a miss became a hard 400.

Widening 998→404 alone is the wrong fix and must not be shipped by itself. A rehearsal healer already did exactly that in a side worktree (logs/healer-claude.out, commit 16182abe). Because the member does have a Nextcloud account, that patch converts this red into a silent green: suspend would skip Nextcloud for a member who is still fully enabled there, quietly breaking ADR 0074's one-switch promise while the drive reports success.

That healer's residual note also claims "the Circles app kills user_oidc JIT provisioning, so no member ever gets a Nextcloud account" — the live box refutes that. The OCA\Circles\...\RequestNetworkException at logs/droplet-journal.txt 02:46:29 / 02:46:44 is real, but its trace enters from GroupMemberAdded after Group::addUser committed; the user row, display name and e2e-crew membership all persisted (see user:info above, lastseen 02:46:45).

What the Circles exception does break is the member's HTTP response: it escapes to index.php, so LoginController::provisionUser never returns a session and the browser gets a 500 page. The sign-in leg still passed, so its landing assertion is too loose to notice. Real, worth its own ticket, but not the cause of this red.

Suspected layer

Product / deployment, in the identity-mapping seam between the kanidm oauth2 client render and the control plane's service ports. Not harness, not infra — the harness reported the failure accurately and the box is healthy.

What plugging it needs

  1. Make the files client match the gate client: add the short-username toggle (kanidm system oauth2 prefer-short-username <client>, the CLI counterpart of preferShortUsername = true) to the nextcloud client oneshot in both internal/clan/files_idp_gateway.go and internal/clan/files.go, with a files_test.go case pinning the emitted line so the two paths cannot drift again. Alternative if bare uids are unwanted: give the service ports an explicit person-id→service-id mapping instead of passing PersonID through raw. The first matches the existing convention (internal/kanidm/auth.go:236-242 already strips @domain from SPNs) and is the cheaper ruling.
  2. Note the migration edge in the ticket: flipping the claim orphans already-provisioned name@domain rows. Fine on a fresh drive, needs a rename step for a live community.
  3. Keep the OCS 404 tolerance fix, but land it with fix 1, and add a seam test asserting suspend actually disables the Nextcloud account — otherwise the tolerance masks the mismatch.
  4. GOTCHAS entry: kanidm's preferred_username is the SPN unless the client opts into short usernames, and any service keyed off that claim will disagree with the control plane's bare person id.

Absent evidence (all expected for a droplet target)

artifacts/journey.json is {"rows": null, "fault": null} — founding rows were never captured. logs/guest-*.log are stubs ("the guest was never created, so there is nothing to ask") and logs/qemu.log is spawn qemu-system-x86_64 ENOENT, matching host.json's "qemu": "exit ENOENT". These are the VM-target collectors idling on a droplet run, not faults.

drive 20260826T023458Z red at invite-member: POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: read user \"e2e-member\" failed: OCS 404 User does not exist"}
evidence: /home/dev/swarm/Matou/idss/test-results/drive-droplet/20260826T023458Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## Failure `invite-member` is the run's only red (`artifacts/verdict.json`: `"firstRedLeg": "invite-member"`, 24 green / 1 red / 1 skip). **This is not the known frontier** — the frontier rows skip with the own-VPS carrier reason (`backup-honest-floor`, and `alert-email` / `rescue-rung` in the leg table), whereas `invite-member` is `reachable: () => true` and actually ran. Suspend move 3 (the Nextcloud reconciler) fails: ``` POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: read user \"e2e-member\" failed: OCS 404 User does not exist"} ``` That message is literally true and badly misleading. There is no Nextcloud user `e2e-member`. There **is** one called `e2e-member@id.rehearsal-b.idss.nz`, and it was created six seconds *before* the suspend. The control plane looked up the wrong id. ## Evidence — the live droplet (134.199.165.229, still up) ssh was accepted; `systemctl --failed` is empty and every service is listening. The Nextcloud user list: ``` - operator@id.rehearsal-b.idss.nz: Drive Operator - e2e-member@id.rehearsal-b.idss.nz: E2E Member - ocadmin: ocadmin ``` ``` $ nextcloud-occ user:info e2e-member user not found $ nextcloud-occ user:info "e2e-member@id.rehearsal-b.idss.nz" - user_id: e2e-member@id.rehearsal-b.idss.nz - display_name: E2E Member - enabled: true - groups: - e2e-crew ``` The account exists, is enabled, carries the right display name and the `e2e-crew` komiti. Timing puts it inside the drive, before the suspend: ``` $ nextcloud-occ user:lastseen "e2e-member@id.rehearsal-b.idss.nz" e2e-member@id.rehearsal-b.idss.nz's last login: 2026-08-26 02:46:45 UTC ``` and the suspend itself is in the journal at 02:46:51 — **move 1 succeeded against kanidm using the bare id** (`logs/droplet-journal.txt`, 02:46:51): ``` method: PUT | uri: /v1/person/e2e-member/_attr/account_expire | status_code: 200 ``` So the same `personID` is valid on kanidm and invalid on Nextcloud. That is the whole bug. ## The chain, in repo terms 1. `internal/clan/files.go:720-721` (and the droplet twin in `internal/clan/files_idp_gateway.go`) provisions user_oidc with the claim used verbatim as the Nextcloud uid: ``` --unique-uid=0 \ --mapping-uid=preferred_username \ ``` 2. The kanidm `nextcloud` oauth2 client is created imperatively (`files_idp_gateway.go:183-206`, `files.go:650-693`) and **never gets the short-username toggle**, so kanidm emits `preferred_username` as the SPN `name@domain`. The *gate* client does set it — `internal/clan/vmguest.go:1212`: `preferShortUsername = true;` (STATUS.md:2137 documents it as part of the gate-oidc client). The files client drifted from that convention. 3. Nextcloud therefore JIT-provisions uid `e2e-member@id.rehearsal-b.idss.nz` (proven above). 4. The control plane stores the bare handle — `internal/member/byhand.go:85`: `PersonID: spec.Username,` — and `internal/member/suspend.go:194` passes it straight through: `return o.reconciler.DisableCredentials(personID)`. 5. `internal/nextcloud/nextcloud.go:264` GETs `/ocs/v1.php/cloud/users/e2e-member` → OCS 404. ## Secondary defect — and a false-green trap `internal/nextcloud/nextcloud.go:351` tolerates only the historical missing-user code: ```go ocsOK = 100 ocsNotFound = 998 ``` Nextcloud 32.0.11 answers `statuscode: 404` in the OCS envelope, so the deliberate "no account here — nothing to reconcile" path at `nextcloud.go:239` never fired and a miss became a hard 400. **Widening 998→404 alone is the wrong fix and must not be shipped by itself.** A rehearsal healer already did exactly that in a side worktree (`logs/healer-claude.out`, commit `16182abe`). Because the member *does* have a Nextcloud account, that patch converts this red into a **silent green**: suspend would skip Nextcloud for a member who is still fully enabled there, quietly breaking ADR 0074's one-switch promise while the drive reports success. That healer's residual note also claims "the Circles app kills user_oidc JIT provisioning, so no member ever gets a Nextcloud account" — **the live box refutes that**. The `OCA\Circles\...\RequestNetworkException` at `logs/droplet-journal.txt` 02:46:29 / 02:46:44 is real, but its trace enters from `GroupMemberAdded` *after* `Group::addUser` committed; the user row, display name and `e2e-crew` membership all persisted (see `user:info` above, `lastseen` 02:46:45). What the Circles exception *does* break is the member's HTTP response: it escapes to `index.php`, so `LoginController::provisionUser` never returns a session and the browser gets a 500 page. The sign-in leg still passed, so its landing assertion is too loose to notice. Real, worth its own ticket, but not the cause of this red. ## Suspected layer **Product / deployment**, in the identity-mapping seam between the kanidm oauth2 client render and the control plane's service ports. Not harness, not infra — the harness reported the failure accurately and the box is healthy. ## What plugging it needs 1. Make the files client match the gate client: add the short-username toggle (`kanidm system oauth2 prefer-short-username <client>`, the CLI counterpart of `preferShortUsername = true`) to the nextcloud client oneshot in **both** `internal/clan/files_idp_gateway.go` and `internal/clan/files.go`, with a `files_test.go` case pinning the emitted line so the two paths cannot drift again. Alternative if bare uids are unwanted: give the service ports an explicit person-id→service-id mapping instead of passing `PersonID` through raw. The first matches the existing convention (`internal/kanidm/auth.go:236-242` already strips `@domain` from SPNs) and is the cheaper ruling. 2. Note the migration edge in the ticket: flipping the claim orphans already-provisioned `name@domain` rows. Fine on a fresh drive, needs a rename step for a live community. 3. Keep the OCS 404 tolerance fix, but land it **with** fix 1, and add a seam test asserting suspend actually disables the Nextcloud account — otherwise the tolerance masks the mismatch. 4. GOTCHAS entry: kanidm's `preferred_username` is the SPN unless the client opts into short usernames, and any service keyed off that claim will disagree with the control plane's bare person id. ## Absent evidence (all expected for a droplet target) `artifacts/journey.json` is `{"rows": null, "fault": null}` — founding rows were never captured. `logs/guest-*.log` are stubs ("the guest was never created, so there is nothing to ask") and `logs/qemu.log` is `spawn qemu-system-x86_64 ENOENT`, matching `host.json`'s `"qemu": "exit ENOENT"`. These are the VM-target collectors idling on a droplet run, not faults. drive `20260826T023458Z` red at `invite-member`: `POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: read user \"e2e-member\" failed: OCS 404 User does not exist"}` evidence: `/home/dev/swarm/Matou/idss/test-results/drive-droplet/20260826T023458Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 1dc3e7a84786 -->
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=10107
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=10107 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #866 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 866,
  "status": "success",
  "commits": [
    "4a91a226f84ab9065bd7dc1ce903c771a56982a1"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/clan/files.go",
    "internal/clan/files_idp_gateway.go",
    "internal/clan/files_idp_gateway_test.go",
    "internal/clan/files_test.go",
    "internal/nextcloud/nextcloud.go",
    "internal/nextcloud/nextcloud_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/nextcloud/... ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/nextcloud/... ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "gofmt -l (touched files)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "files kanidm client emits the short username in both render paths": "internal/clan/files.go and internal/clan/files_idp_gateway.go both emit `kanidm system oauth2 prefer-short-username nextcloud --name idm_admin`; commit 4a91a22",
    "the emitted line is pinned so the two paths cannot drift again": "files_test.go:TestRenderFiles_OIDCProvisionsKanidmClient and files_idp_gateway_test.go:TestRenderFilesIDPClient_GatewayOneshotOwnsKanidmAndSharesSecret both assert the prefer-short-username line; both PASS",
    "OCS 404 tolerance kept but landed WITH the short-username fix, not alone": "nextcloud.go ocsMeta.notFound() accepts 998 and 404, shipped in the same commit as fix 1",
    "seam test asserts suspend actually disables the Nextcloud account (no silent green)": "nextcloud_test.go:TestNotFound_404Envelope_IsToleratedButRealAccountStillDisabled PASSES — a 404 miss no-ops, a real account is still actually disabled",
    "GOTCHAS entry recorded": "docs/GOTCHAS.md #88 (preferred_username is the SPN unless the client opts into short usernames)",
    "migration edge noted": "STATUS.md milestone entry and GOTCHAS #88 both note flipping the claim orphans name@domain rows on a live community and needs a rename step"
  },
  "summary": "The files kanidm nextcloud oauth2 client now emits the short username (matching the gate client), so suspend's bare person id matches user_oidc's JIT'd uid; OCS 404 tolerance added alongside with a false-green-guarding seam test.",
  "blockers": []
}
**close-report** for #866 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 866, "status": "success", "commits": [ "4a91a226f84ab9065bd7dc1ce903c771a56982a1" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/clan/files.go", "internal/clan/files_idp_gateway.go", "internal/clan/files_idp_gateway_test.go", "internal/clan/files_test.go", "internal/nextcloud/nextcloud.go", "internal/nextcloud/nextcloud_test.go" ], "tests": [ { "command": "go test ./internal/nextcloud/... ./internal/clan/", "exit_code": 0 }, { "command": "go vet ./internal/nextcloud/... ./internal/clan/", "exit_code": 0 }, { "command": "gofmt -l (touched files)", "exit_code": 0 } ], "criteria": { "files kanidm client emits the short username in both render paths": "internal/clan/files.go and internal/clan/files_idp_gateway.go both emit `kanidm system oauth2 prefer-short-username nextcloud --name idm_admin`; commit 4a91a22", "the emitted line is pinned so the two paths cannot drift again": "files_test.go:TestRenderFiles_OIDCProvisionsKanidmClient and files_idp_gateway_test.go:TestRenderFilesIDPClient_GatewayOneshotOwnsKanidmAndSharesSecret both assert the prefer-short-username line; both PASS", "OCS 404 tolerance kept but landed WITH the short-username fix, not alone": "nextcloud.go ocsMeta.notFound() accepts 998 and 404, shipped in the same commit as fix 1", "seam test asserts suspend actually disables the Nextcloud account (no silent green)": "nextcloud_test.go:TestNotFound_404Envelope_IsToleratedButRealAccountStillDisabled PASSES — a 404 miss no-ops, a real account is still actually disabled", "GOTCHAS entry recorded": "docs/GOTCHAS.md #88 (preferred_username is the SPN unless the client opts into short usernames)", "migration edge noted": "STATUS.md milestone entry and GOTCHAS #88 both note flipping the claim orphans name@domain rows on a live community and needs a rename step" }, "summary": "The files kanidm nextcloud oauth2 client now emits the short username (matching the gate client), so suspend's bare person id matches user_oidc's JIT'd uid; OCS 404 tolerance added alongside with a false-green-guarding seam test.", "blockers": [] } ``` </details>
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.

Reference
Matou/idss#866
No description provided.