fix: no rename on a case-only login difference, stop on an unreachable forgejo #69

Sammanfogat
supernaut sammanfogade 2 incheckningar från fix/classify-profile-case in i main 2026-10-03 19:15:52 +00:00
Ägare

What

  1. classifyProfile compares the Kanidm name and the Forgejo login with ownerKey (lower case), not !==.
  2. A network error (adapter status 0) now aborts the run in the places that ignored it or counted it as a refusal.

Why

  1. Forgejo logins are case-insensitive. A case-only difference produced a rename with nothing to change, recomputed every tick, flagged as an identity failure. Same root cause as #28, different call site.
  2. With Forgejo unreachable mid-run, the identity loop, quota removals, Actions toggle, Renovate step and legacy purge carried on through every remaining account. The purge was logged as done. Quota adds already aborted on status 0, so nothing was demoted, but the run did not stop and did not always report.

How

  • assertReachable(status, what) in reconcile.ts throws on status 0. A non-zero refusal (403, 422) keeps its existing best-effort handling.
  • main already turns a throw into exit 1 and the failure metric.
  • FakeForgejo gets downWhen: from the matching call on, status methods return 0 and reads throw, as the real adapter does.

Tested

Tests written first. 3 case tests (2 unit, 1 reconcile) and 11 unreachable tests: user add, quota removal, org add, repo list, repo patch, identity rename, legacy purge, Renovate repo list, collaborator add, collaborator remove, profile update. Each asserts the run rejects with the unreachable message and that no call follows the first failed one.
All new tests fail without the fix except the user-add and org-add tests, which are regression guards (those adds already aborted on status 0). Each of the four later-added abort sites was checked by removing its assertReachable call.
listOwnerRepos returns 502 for a 200 reply that is not JSON, so a bad body stays best-effort and is not read as unreachable.
pnpm test 136 passed, pnpm lint clean, pnpm typecheck clean.

Open questions

  • A case-only Kanidm rename (Alice to alice) is not projected onto the Forgejo login, so the displayed casing stays as Forgejo has it. Kanidm names are lower case in practice. Say if the casing should be projected.
  • Status 0 now aborts the Actions and Renovate steps, which were best-effort. Scope refusals (403) stay best-effort.
  • No release or version bump here.
## What 1. `classifyProfile` compares the Kanidm name and the Forgejo login with `ownerKey` (lower case), not `!==`. 2. A network error (adapter status 0) now aborts the run in the places that ignored it or counted it as a refusal. ## Why 1. Forgejo logins are case-insensitive. A case-only difference produced a rename with nothing to change, recomputed every tick, flagged as an identity failure. Same root cause as #28, different call site. 2. With Forgejo unreachable mid-run, the identity loop, quota removals, Actions toggle, Renovate step and legacy purge carried on through every remaining account. The purge was logged as done. Quota adds already aborted on status 0, so nothing was demoted, but the run did not stop and did not always report. ## How - `assertReachable(status, what)` in `reconcile.ts` throws on status 0. A non-zero refusal (403, 422) keeps its existing best-effort handling. - `main` already turns a throw into exit 1 and the failure metric. - `FakeForgejo` gets `downWhen`: from the matching call on, status methods return 0 and reads throw, as the real adapter does. ## Tested Tests written first. 3 case tests (2 unit, 1 reconcile) and 11 unreachable tests: user add, quota removal, org add, repo list, repo patch, identity rename, legacy purge, Renovate repo list, collaborator add, collaborator remove, profile update. Each asserts the run rejects with the unreachable message and that no call follows the first failed one. All new tests fail without the fix except the user-add and org-add tests, which are regression guards (those adds already aborted on status 0). Each of the four later-added abort sites was checked by removing its `assertReachable` call. `listOwnerRepos` returns 502 for a 200 reply that is not JSON, so a bad body stays best-effort and is not read as unreachable. `pnpm test` 136 passed, `pnpm lint` clean, `pnpm typecheck` clean. ## Open questions - A case-only Kanidm rename (Alice to alice) is not projected onto the Forgejo login, so the displayed casing stays as Forgejo has it. Kanidm names are lower case in practice. Say if the casing should be projected. - Status 0 now aborts the Actions and Renovate steps, which were best-effort. Scope refusals (403) stay best-effort. - No release or version bump here.
supernaut lade till 2 incheckningar 2026-10-03 00:13:40 +00:00
classifyProfile compared the Kanidm name and the Forgejo login
case-sensitively. Forgejo logins are case-insensitive, so a case-only
difference produced a rename that has nothing to change, and the diff
was recomputed every tick. It now compares with ownerKey, as the owner
matching does.

The adapter maps a network error to status 0. Several callers ignored
the status or counted it as a refusal, so a Forgejo that dropped out
mid-run was walked through every remaining account (identity writes,
quota removals, the Actions toggle, the Renovate step, the legacy
purge) and the purge was logged as done. Those calls now abort the run
on status 0. The run exits non-zero and writes the failure metric.
Nothing is demoted on a network error: quota adds already aborted.

The Forgejo fake gains downWhen to cut the connection at a chosen call.
test: cover the remaining unreachable-forgejo abort sites
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m9s
dcf5b8a0bf
The Renovate repo list, collaborator add, collaborator remove and
profile update abort sites had no test. Each now has one that fails
with its assertReachable call removed. The other unreachable tests
now match the error message, so the cause is pinned.

The doc comments on the Actions, Renovate and identity steps said they
never abort. They now say they stop on status 0 and stay best-effort
on refusals.

listOwnerRepos returned status 0 when a 200 reply was not JSON, which
now reads as unreachable. It returns 502 for that, so a bad body stays
best-effort.
supernaut sammanfogade incheckning 08e063e7e7 till main 2026-10-03 19:15:52 +00:00
supernaut tog bort grenen fix/classify-profile-case 2026-10-03 19:15:53 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-04 06:04:15 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-auth-reconciler!69
Ingen beskrivning angiven.