invite-member red: the Nextcloud reconciler cannot reach the OCS API — /ocs is gated at the front door and the control plane carries no admin credential #790

Closed
opened 2026-08-25 05:22:43 +00:00 by matou-build-agent · 2 comments

Failure

Drive 20260825T050659Z (droplet, commit b8b71ce7) — leg invite-member red at 24 green / 1 red / 1 skip:

POST /api/v1/members/e2e-member/suspend failed: 400
{"code":"act_failed","message":"nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: cannot parse OCS response: invalid character '<' looking for beginning of value"}

The by-hand create, komiti materialisation and the member's own OIDC sign-in all passed; the leg dies on the FIRST OCS call the suspend makes — Port.user's read at internal/nextcloud/nextcloud.go:214, reached from setEnabled (internal/nextcloud/nextcloud.go:184-191) via DisableCredentials (:168).

Defect 1 — /ocs is not exempt from the browser gate

The reconciler drives the DERIVED public files URL (https://files.rehearsal-b.idss.nz, control-plane/cmd/control-plane/main.go:249-254), so every OCS call goes through the front door. The files route's exempt list carries the DAV sync paths and /status.php but NOT the OCS Provisioning API:

  • internal/clan/files.go:74-79 — FilesExemptPaths = /remote.php/dav*, /remote.php/webdav*, /public.php/dav*, /status.php
  • internal/provision/deploy.go:602 — that list IS the public route's ExemptPaths
  • internal/clan/frontdoor.go:428-437 — everything not exempt falls into the handle { forward_auth ... } block
  • internal/clan/frontdoor.go:466-470 — the gate's 401 becomes a 302 to https://<apex>/authz/signin

The reconciler's http.DefaultClient follows that redirect into the sign-in flow and reads back an HTML page. Port.request only special-cases 401/403 and >=500 (internal/nextcloud/nextcloud.go:264-269), so the HTML falls straight into json.Unmarshal at :277 — the '<' in the error is the sign-in page's first byte, not Nextcloud's.

Corroboration: the files health probe went green in the same run (droplet-journal.txt:1858, verdict=healthy) because /status.php IS exempt — the exempt mechanism works; /ocs is simply missing from the list.

Precedent settles the shape. The two sibling reconciler ports already exempt their credential-authenticated management APIs:

  • internal/clan/code.go:83 — CodeExemptPaths carries /api/v1/* (the token-auth Forgejo REST API the code reconciler drives)
  • internal/clan/chat.go:92 — ChatExemptPaths carries /api/v4/* (the token-auth Mattermost API the chat reconciler drives)

Files is the odd one out. Recommend the NARROW form rather than a blanket /ocs/*, since /ocs also carries user-facing sharing endpoints that should stay behind the gate:

"/ocs/v1.php/cloud/users*",

That is the only OCS subtree internal/nextcloud touches (nextcloud.go:199 and :214). It is credential-governed exactly as the DAV paths are — Nextcloud refuses the OCS Provisioning API without the admin's basic auth — so the ADR 0074 posture holds.

Defect 2 — the control plane carries no Nextcloud admin credential

Even past the gate the call 401s. From the same run:

droplet-journal.txt:1018  msg="member offboard: Nextcloud reconciler port wired over the derived files URL"
                          url=https://files.rehearsal-b.idss.nz admin=""

admin="" — IDSS_NEXTCLOUD_ADMIN_USER / IDSS_NEXTCLOUD_ADMIN_PASSWORD (control-plane/cmd/control-plane/main.go:252) are read but never set anywhere outside tests. A repo-wide grep finds only main.go:252 and offboard_catalogue_test.go:63-64. The rendered unit confirms it: state/clan-config/machines/gateway/control-plane.nix:313-325 exports the KANIDM / ALERT / CLAIM / ACCESS / GATE_OIDC vars and no IDSS_NEXTCLOUD_*.

The two halves the credential needs already exist and just aren't joined:

  • the identity — internal/clan/files_attach.go:44, NextcloudAdminUser = "ocadmin", documented as "the admin service identity the module deploys AND the member-orbit reconciler authenticates as (one identity, ADR 0062 part 2)"
  • the secret — the nextcloud-admin clan-vars generator, internal/clan/files.go:338-344 (files.adminpass, owner nextcloud, mode 0400). The control-plane unit runs as root (no User= in control-plane.nix:280-303), so it can read that path.

Suspected layer

Provisioning render, both halves — internal/clan (front-door exempt list + control-plane env exports) with internal/provision/deploy.go as the caller. NOT the internal/nextcloud adapter: it is doing the right thing over a door that refuses it with no credential to present.

What plugging it needs

  1. Exempt the OCS Provisioning subtree. Add "/ocs/v1.php/cloud/users*" to FilesExemptPaths (internal/clan/files.go:74-79) and extend the comment the way code.go:64-82 does — naming the reconciler as the credential-governed caller. Cover it in internal/clan/files_frontdoor_test.go alongside the existing /status.php pin.

  2. Thread the admin credential into the control-plane unit. Emit IDSS_NEXTCLOUD_ADMIN_USER=ocadmin and IDSS_NEXTCLOUD_ADMIN_PASSWORD from the nextcloud-admin generator in gatewayEnvExports (internal/clan/vmguest.go:1329-1366). The password follows varSecretExport (vmguest.go:1372) — note it reads files.secret.path, whereas this generator's file is named adminpass, so it needs its own line rather than that helper.

  3. Gate the export on files actually being placed, and mind the render order. The nextcloud-admin generator is declared by the FILES module (files.go:338), which does not exist at founding — an ungated config.clan.core.vars.generators.nextcloud-admin reference in control-plane.nix is an eval error on any community without files. Gate it on a new GatewayFacts flag the way SMTPSubmission / ClaimSecret / CommunityApex already gate theirs, and make sure the control-plane surface is RE-rendered after attachFiles so the gateway switch carries the export. Both gateway renders must carry it — the own-VPS box runs the full-install render (the DUAL-RENDER hazard, GOTCHAS #12).

  4. Consider an eval assertion in the files/control-plane pair, matching control-plane.nix:326+, so a files-placed gateway missing the export fails eval with the remedy rather than reding this leg one drive later.

Both halves must land in one change. Shipping only the exempt path moves the failure from an HTML parse to nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: unauthorised (HTTP 401) — check the admin credential (internal/nextcloud/nextcloud.go:265) and burns another droplet on the same leg.

Side observation (not the defect)

The control plane logged nothing when the act failed — no idss-control-plane line at 05:17:57 in droplet-journal.txt, only the 05:17:26 health probe. The whole diagnosis had to come off the Playwright error string. A failed member act reaching a service port is worth a WARN.

drive 20260825T050659Z red at invite-member: POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: cannot parse OCS response: invalid character '\u003c' looking for
evidence: test-results/…/20260825T050659Z/ on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)

## Failure Drive `20260825T050659Z` (droplet, commit `b8b71ce7`) — leg `invite-member` red at 24 green / 1 red / 1 skip: ``` POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: cannot parse OCS response: invalid character '<' looking for beginning of value"} ``` The by-hand create, komiti materialisation and the member's own OIDC sign-in all passed; the leg dies on the FIRST OCS call the suspend makes — `Port.user`'s read at `internal/nextcloud/nextcloud.go:214`, reached from `setEnabled` (`internal/nextcloud/nextcloud.go:184-191`) via `DisableCredentials` (`:168`). ## Defect 1 — `/ocs` is not exempt from the browser gate The reconciler drives the DERIVED public files URL (`https://files.rehearsal-b.idss.nz`, `control-plane/cmd/control-plane/main.go:249-254`), so every OCS call goes through the front door. The files route's exempt list carries the DAV sync paths and `/status.php` but NOT the OCS Provisioning API: - `internal/clan/files.go:74-79` — `FilesExemptPaths` = `/remote.php/dav*`, `/remote.php/webdav*`, `/public.php/dav*`, `/status.php` - `internal/provision/deploy.go:602` — that list IS the public route's `ExemptPaths` - `internal/clan/frontdoor.go:428-437` — everything not exempt falls into the `handle { forward_auth ... }` block - `internal/clan/frontdoor.go:466-470` — the gate's 401 becomes a **302 to `https://<apex>/authz/signin`** The reconciler's `http.DefaultClient` follows that redirect into the sign-in flow and reads back an HTML page. `Port.request` only special-cases 401/403 and >=500 (`internal/nextcloud/nextcloud.go:264-269`), so the HTML falls straight into `json.Unmarshal` at `:277` — the `'<'` in the error is the sign-in page's first byte, not Nextcloud's. Corroboration: the files health probe went green in the same run (`droplet-journal.txt:1858`, `verdict=healthy`) because `/status.php` IS exempt — the exempt mechanism works; `/ocs` is simply missing from the list. **Precedent settles the shape.** The two sibling reconciler ports already exempt their credential-authenticated management APIs: - `internal/clan/code.go:83` — `CodeExemptPaths` carries `/api/v1/*` (the token-auth Forgejo REST API the code reconciler drives) - `internal/clan/chat.go:92` — `ChatExemptPaths` carries `/api/v4/*` (the token-auth Mattermost API the chat reconciler drives) Files is the odd one out. Recommend the NARROW form rather than a blanket `/ocs/*`, since `/ocs` also carries user-facing sharing endpoints that should stay behind the gate: ```go "/ocs/v1.php/cloud/users*", ``` That is the only OCS subtree `internal/nextcloud` touches (`nextcloud.go:199` and `:214`). It is credential-governed exactly as the DAV paths are — Nextcloud refuses the OCS Provisioning API without the admin's basic auth — so the ADR 0074 posture holds. ## Defect 2 — the control plane carries no Nextcloud admin credential Even past the gate the call 401s. From the same run: ``` droplet-journal.txt:1018 msg="member offboard: Nextcloud reconciler port wired over the derived files URL" url=https://files.rehearsal-b.idss.nz admin="" ``` `admin=""` — `IDSS_NEXTCLOUD_ADMIN_USER` / `IDSS_NEXTCLOUD_ADMIN_PASSWORD` (`control-plane/cmd/control-plane/main.go:252`) are read but **never set anywhere outside tests**. A repo-wide grep finds only `main.go:252` and `offboard_catalogue_test.go:63-64`. The rendered unit confirms it: `state/clan-config/machines/gateway/control-plane.nix:313-325` exports the KANIDM / ALERT / CLAIM / ACCESS / GATE_OIDC vars and no `IDSS_NEXTCLOUD_*`. The two halves the credential needs already exist and just aren't joined: - the identity — `internal/clan/files_attach.go:44`, `NextcloudAdminUser = "ocadmin"`, documented as "the admin service identity the module deploys AND the member-orbit reconciler authenticates as (one identity, ADR 0062 part 2)" - the secret — the `nextcloud-admin` clan-vars generator, `internal/clan/files.go:338-344` (`files.adminpass`, owner `nextcloud`, mode 0400). The control-plane unit runs as root (no `User=` in `control-plane.nix:280-303`), so it can read that path. ## Suspected layer Provisioning render, both halves — `internal/clan` (front-door exempt list + control-plane env exports) with `internal/provision/deploy.go` as the caller. NOT the `internal/nextcloud` adapter: it is doing the right thing over a door that refuses it with no credential to present. ## What plugging it needs 1. **Exempt the OCS Provisioning subtree.** Add `"/ocs/v1.php/cloud/users*"` to `FilesExemptPaths` (`internal/clan/files.go:74-79`) and extend the comment the way `code.go:64-82` does — naming the reconciler as the credential-governed caller. Cover it in `internal/clan/files_frontdoor_test.go` alongside the existing `/status.php` pin. 2. **Thread the admin credential into the control-plane unit.** Emit `IDSS_NEXTCLOUD_ADMIN_USER=ocadmin` and `IDSS_NEXTCLOUD_ADMIN_PASSWORD` from the `nextcloud-admin` generator in `gatewayEnvExports` (`internal/clan/vmguest.go:1329-1366`). The password follows `varSecretExport` (`vmguest.go:1372`) — note it reads `files.secret.path`, whereas this generator's file is named `adminpass`, so it needs its own line rather than that helper. 3. **Gate the export on files actually being placed, and mind the render order.** The `nextcloud-admin` generator is declared by the FILES module (`files.go:338`), which does not exist at founding — an ungated `config.clan.core.vars.generators.nextcloud-admin` reference in `control-plane.nix` is an eval error on any community without files. Gate it on a new `GatewayFacts` flag the way `SMTPSubmission` / `ClaimSecret` / `CommunityApex` already gate theirs, and make sure the control-plane surface is RE-rendered after `attachFiles` so the gateway switch carries the export. Both gateway renders must carry it — the own-VPS box runs the full-install render (the DUAL-RENDER hazard, GOTCHAS #12). 4. **Consider an eval assertion** in the files/control-plane pair, matching `control-plane.nix:326+`, so a files-placed gateway missing the export fails eval with the remedy rather than reding this leg one drive later. **Both halves must land in one change.** Shipping only the exempt path moves the failure from an HTML parse to `nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: unauthorised (HTTP 401) — check the admin credential` (`internal/nextcloud/nextcloud.go:265`) and burns another droplet on the same leg. ## Side observation (not the defect) The control plane logged nothing when the act failed — no `idss-control-plane` line at 05:17:57 in `droplet-journal.txt`, only the 05:17:26 health probe. The whole diagnosis had to come off the Playwright error string. A failed member act reaching a service port is worth a WARN. drive `20260825T050659Z` red at `invite-member`: `POST /api/v1/members/e2e-member/suspend failed: 400 {"code":"act_failed","message":"nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: cannot parse OCS response: invalid character '\u003c' looking for` evidence: `test-results/…/20260825T050659Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596) <!-- rehearsal-sig: 1dc3e7a84786 -->
Author
Member

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

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

close-report for #790 — status success

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

envelope
{
  "issue": 790,
  "status": "success",
  "commits": [
    "cf76897"
  ],
  "changed_files": [
    "STATUS.md",
    "control-plane/cmd/control-plane/resting_composition.go",
    "internal/clan/clan.go",
    "internal/clan/enrollment.go",
    "internal/clan/files.go",
    "internal/clan/files_attach.go",
    "internal/clan/files_frontdoor_test.go",
    "internal/clan/gateway_attach.go",
    "internal/clan/gateway_attach_test.go",
    "internal/clan/testing/fake.go",
    "internal/clan/vmguest.go",
    "internal/provision/deploy.go",
    "internal/provision/deploy_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/clan/ ./internal/provision/ ./internal/founding/ ./control-plane/...",
      "exit_code": 0
    },
    {
      "command": "gofmt -l internal/clan/ internal/provision/ control-plane/cmd/control-plane/",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/clan/ ./internal/provision/ ./internal/founding/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Defect 1 — /ocs exempt from the browser gate": "internal/clan/files.go: added \"/ocs/v1.php/cloud/users*\" to FilesExemptPaths with an extended comment naming the reconciler as the credential-governed caller; pinned by TestFilesExemptPaths_ExemptTheOCSProvisioningAPI in files_frontdoor_test.go (exempt handle carries no forward_auth)",
    "Defect 2 — admin credential threaded into the control-plane unit": "internal/clan/vmguest.go gatewayEnvExports emits IDSS_NEXTCLOUD_ADMIN_USER=ocadmin and IDSS_NEXTCLOUD_ADMIN_PASSWORD from the nextcloud-admin generator's adminpass .path (its own line, not varSecretExport); names match main.go:252",
    "Gated on files placed + re-render after attachFiles + both renders": "GatewayFacts.NextcloudAdmin gates the export (clan.go); Adapter.EnableGatewayNextcloudExport (gateway_attach.go) re-renders the surface WHOLE reading founding facts back from the gateway-render.json sidecar (persisted at both enrollment render sites, enrollment.go); wired in attachFilesCohost before ComposeGatewayCohost (deploy.go). TestEnableGatewayNextcloudExport_FullInstall proves SMTP/claim/access exports survive; _VMPath proves gateway-guest.nix is rewritten with keys preserved; deploy_test asserts call order",
    "Eval assertion": "internal/clan/vmguest.go gatewayControlPlaneAssertions adds an assertion (gated on NextcloudAdmin) that the nextcloud-admin generator + adminpass file are declared, with the remedy; asserted present in TestEnableGatewayNextcloudExport_FullInstall",
    "Both halves land in one change": "single commit cf76897 carries the exempt path AND the credential export"
  },
  "summary": "Exempted the OCS Provisioning subtree at the front door and threaded the Nextcloud admin credential into the control-plane unit via a files-gated GatewayFacts flag and a post-attachFiles whole re-render that preserves every founding export.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #790 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 790, "status": "success", "commits": [ "cf76897" ], "changed_files": [ "STATUS.md", "control-plane/cmd/control-plane/resting_composition.go", "internal/clan/clan.go", "internal/clan/enrollment.go", "internal/clan/files.go", "internal/clan/files_attach.go", "internal/clan/files_frontdoor_test.go", "internal/clan/gateway_attach.go", "internal/clan/gateway_attach_test.go", "internal/clan/testing/fake.go", "internal/clan/vmguest.go", "internal/provision/deploy.go", "internal/provision/deploy_test.go" ], "tests": [ { "command": "go test ./internal/clan/ ./internal/provision/ ./internal/founding/ ./control-plane/...", "exit_code": 0 }, { "command": "gofmt -l internal/clan/ internal/provision/ control-plane/cmd/control-plane/", "exit_code": 0 }, { "command": "go vet ./internal/clan/ ./internal/provision/ ./internal/founding/", "exit_code": 0 } ], "criteria": { "Defect 1 — /ocs exempt from the browser gate": "internal/clan/files.go: added \"/ocs/v1.php/cloud/users*\" to FilesExemptPaths with an extended comment naming the reconciler as the credential-governed caller; pinned by TestFilesExemptPaths_ExemptTheOCSProvisioningAPI in files_frontdoor_test.go (exempt handle carries no forward_auth)", "Defect 2 — admin credential threaded into the control-plane unit": "internal/clan/vmguest.go gatewayEnvExports emits IDSS_NEXTCLOUD_ADMIN_USER=ocadmin and IDSS_NEXTCLOUD_ADMIN_PASSWORD from the nextcloud-admin generator's adminpass .path (its own line, not varSecretExport); names match main.go:252", "Gated on files placed + re-render after attachFiles + both renders": "GatewayFacts.NextcloudAdmin gates the export (clan.go); Adapter.EnableGatewayNextcloudExport (gateway_attach.go) re-renders the surface WHOLE reading founding facts back from the gateway-render.json sidecar (persisted at both enrollment render sites, enrollment.go); wired in attachFilesCohost before ComposeGatewayCohost (deploy.go). TestEnableGatewayNextcloudExport_FullInstall proves SMTP/claim/access exports survive; _VMPath proves gateway-guest.nix is rewritten with keys preserved; deploy_test asserts call order", "Eval assertion": "internal/clan/vmguest.go gatewayControlPlaneAssertions adds an assertion (gated on NextcloudAdmin) that the nextcloud-admin generator + adminpass file are declared, with the remedy; asserted present in TestEnableGatewayNextcloudExport_FullInstall", "Both halves land in one change": "single commit cf76897 carries the exempt path AND the credential export" }, "summary": "Exempted the OCS Provisioning subtree at the front door and threaded the Nextcloud admin credential into the control-plane unit via a files-gated GatewayFacts flag and a post-attachFiles whole re-render that preserves every founding export.", "reason": "", "blockers": [], "no_code_change": "" } ``` </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#790
No description provided.