fix(keycloak): resolve an organization by alias, not by display name #30

Merged
sharang merged 1 commits from fix/org-lookup-by-alias into main 2026-09-14 11:30:01 +00:00
Owner

Found while seeding the real demo tenant: Keycloak has one member in that organization, the registry reported none, and the portal's Team page therefore says "Nobody has been invited yet" for every tenant. Invites from that page would have failed the same way, since they resolve the organization first.

The lookup asked for ?search=<slug>&exact=true. In KC 26 exact compares the display name, and the registry names organizations after the company (Breakpilot Demo GmbH) while the alias carries the slug (demo). Reproduced against the live realm:

query result
?search=demo&exact=true 0
?search=demo 3 (demo, stage-demo, stage-demo-1156)
?q=alias:demo 1 (the right one)

So it now asks q=alias:<slug> first and falls back to the substring search, comparing the alias in both cases — the substring form matches neighbours, and a tenant called demo must never resolve to stage-demo.

The test fake now mirrors KC 26's three behaviours (alias query, substring search, name-based exact) instead of answering only the exact form it was handed, which is why the original bug passed its tests. The regression test covers the name/alias mismatch, the neighbouring slug and a genuine miss.

This is a defect in #28, mine, and it blocks the Team page and invites in the demo walkthrough.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Found while seeding the real `demo` tenant: Keycloak has one member in that organization, the registry reported none, and the portal's Team page therefore says "Nobody has been invited yet" for **every** tenant. Invites from that page would have failed the same way, since they resolve the organization first. The lookup asked for `?search=<slug>&exact=true`. In KC 26 `exact` compares the **display name**, and the registry names organizations after the company (`Breakpilot Demo GmbH`) while the alias carries the slug (`demo`). Reproduced against the live realm: | query | result | |---|---| | `?search=demo&exact=true` | 0 | | `?search=demo` | 3 (`demo`, `stage-demo`, `stage-demo-1156`) | | `?q=alias:demo` | 1 (the right one) | So it now asks `q=alias:<slug>` first and falls back to the substring search, comparing the alias in both cases — the substring form matches neighbours, and a tenant called `demo` must never resolve to `stage-demo`. The test fake now mirrors KC 26's three behaviours (alias query, substring search, name-based `exact`) instead of answering only the exact form it was handed, which is why the original bug passed its tests. The regression test covers the name/alias mismatch, the neighbouring slug and a genuine miss. This is a defect in #28, mine, and it blocks the Team page and invites in the demo walkthrough. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-14 11:05:32 +00:00
fix(keycloak): resolve an organization by alias, not by display name
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 22m31s
ci / image (pull_request) Skipped
7a269b773d
Every Team page came back empty and every invite would have failed: the
organization lookup asked Keycloak for search=<slug>&exact=true, but exact
compares the display name, and the registry names organizations after the
company while the alias carries the slug. The demo tenant proved it — Keycloak
listed one member, the registry reported none.

It now asks for q=alias:<slug> and falls back to a substring search, comparing
the alias in both cases so a neighbouring slug (demo beside stage-demo) is
never returned instead. The fake in the tests now mirrors KC 26's three query
behaviours, and a regression test covers the name/alias mismatch, the
neighbour and the genuine miss.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang merged commit 33ba32ef30 into main 2026-09-14 11:30:01 +00:00
Sign in to join this conversation.