Repository navigation
feat(domain): apply the global navbar domain filter server-side from a persisted defaultDomain - #33908
Conversation
The global (navbar) domain filter is a strict domain-membership condition, so applying it to types that are not domain-scoped in practice (user/team/policy/ tag/...) empties their lists — Settings pages, permission data, tag pickers. Guard getDomainCondition with an explicit allowlist of domain-scoped catalog assets and governance artifacts. Absent entityType (legacy ?domain= callers) is unchanged; safe-by-default: new entity types are not filtered until added.
…enylist Replace the ~30-entry hardcoded allowlist with the intrinsic EntityRepository.supportsDomains flag (auto-covers new domain-scoped entities, nothing to maintain) plus a small, stable DomainFilterExclusions denylist for domain-supporting types whose lists double as reference/ settings surfaces (user/team/tag/classification). The applies-to rule is supportsDomains && !isExcluded(entityType), composed at the injection point; ListFilter keeps the !isExcluded defensive half for legacy ?domain= callers.
…t path Persist the navbar domain on the user (defaultDomain on user.json). JwtFilter reads it via the cached SubjectCache into a request-scoped SelectedDomainContext (mirrors ActivePersonaContext; skipped for bots, best-effort). The paginated list path (listAfter/listBefore/listWithOffset) applies it through DomainNavFilter when supportsDomains && !excluded && no explicit ?domain= — internal listAll and reindex bypass it. testCase joins the exclusions (it inherits its domain and never materializes one, so strict membership would empty data-quality lists). Sub-domain descendant expansion and cache invalidation on domain move/delete are the next step; this applies the exact selected domain.
…t hook Move the view-lens injection into EntityUtil.addDomainQueryParam — the one hook every EntityResource.listInternal already calls — and read the persisted defaultDomain from the already-cached subjectContext there. This removes the per-repository injection (which the three listAfter/listBefore overrides bypassed) and the JwtFilter/SelectedDomainContext/PerRequestContextCleaner plumbing, which were equivalent but reached the auth layer. The domain-only-role enforcement path in the same hook is unchanged; the view filter only applies where that enforcement did not, never to bots, and yields to an explicit ?domain=. Covered by EntityUtilTest.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
…AC scope A DomainOnlyAccessRole user kept the full role scope in list views no matter which domain they picked in the navbar, because the enforcement branch set domainId first and the view filter yielded to it. Narrow that branch to the persisted defaultDomain when it is one of the user's assigned domains, keeping domainAccessControl=true so domainless entities behave exactly as before. A pick outside the role's scope — only reachable by setting defaultDomain through the API, since the navbar never lists such a domain — falls back to the full scope: the filter can narrow within RBAC but never widen past it.
…ed' into fix/global-domain-filter-persisted
…ry list Review found the feature had no working write path: UserUpdater recorded no change for defaultDomain, so a PATCH that only set the navbar selection was dropped, and the cached subject was never evicted. Record the change, evict the cache, require the reference to resolve to a real domain, and add defaultDomain to the user patch/update field sets. Covered by ITs that PATCH, re-read, clear, and reject an unknown domain. Drop the ListFilter exclusion guard: it ran before domainAccessControl and could pre-empt DomainOnlyAccessRole scoping for callers that pass entityType; the exclusion is already decided at the injection point (DomainNavFilter.shouldApply). GlossaryTermResource.list bypasses listInternal, so it never reached the central hook; stamp the filter there — the glossary listing was the originally reported gap.
…main The server now scopes list views from the user's persisted defaultDomain, but nothing in the UI wrote it, so the feature was only reachable through the API. Seed the navbar from defaultDomain at login (before the existing single- restricted-domain rule, which stays as the fallback), and persist each switch with a best-effort JSON-Patch `add` (an upsert: covers first-set, change, and clear via null). The store updates first so a failed write never blocks navigation; the app-store user is refreshed from the response. The ?domain= request interceptor is intentionally kept: several resources still read it directly, and the server's explicit-domain precedence makes the overlap a no-op rather than a conflict.
…ed' into fix/global-domain-filter-persisted
Performance at scaleShort version: users who haven't picked a domain, bots and personal access tokens run exactly the same SQL as before, so there's no cost to them. With a domain picked, list latency at 250k tables was 10–20x the no-pick time. The new commit What
|
| List | No pick | P0 (top-level, 18.5k tables): before → after | Sub-domain (5k): before → after | Empty domain: before → after |
|---|---|---|---|---|
| All tables (250k), no schema: API only, see note ¹ | 22 | 312 → 80 | 95 → 151 ¹ | 4 → 6 |
| Schema, 200k tables | 31 | 285 → 59 | 100 → 58 | 11 (p95 332) → 7 (p95 9) |
| Schema, 5k tables (typical) | 12 | 248 → 34 | 66 → 29 | 13 → 6 |
| Schema, 50k tables owned by P1, P1 picked (inherited) | 15 | 195 → 147 | ||
| Glossaries | 5 | 3 → 4 | 4 → 5 | 5 → 4 |
"Before" is this PR before 874ecb26ff, run on the same data.
¹ The only slower cell. The UI never sends this request: every UI call to /tables passes databaseSchema (SchemaTablesTab, DatabaseSchemaPage, DatabaseSchemaVersionPage, EntitySummaryPanelUtilsV1), and bots and personal access tokens skip the filter. See "Remaining edge cases" for the cause.
MySQL 8.0: query time from EXPLAIN ANALYZE, ms (same data and indexes)
| Pick | List | Count: old → new | Page: old → new |
|---|---|---|---|
| P0 (16k tables) | All tables | 108 → 49 | 102 → 59 |
| P0 (16k tables) | Schema, 200k | 96 → 52 | 106 → 56 |
| Sub-domain (4k) | All tables | 23 → 11 | 26 → 11 |
| Sub-domain (4k) | Schema, 200k | 24 → 10 | 25 → 11 |
| Empty domain | Any | 0 → 0 | 0 → 0 |
Remaining edge cases, both proportional to one list's size
- A small sub-domain on the unscoped
/tableslist (no schema) went from 95 to 151 ms on Postgres. The query does less work than before (count about 55 → 20 ms; the page needs about 2.6k index probes, 11 ms when run serially). Postgres underestimates the sub-domain's tables (about 500 against 5,000), so it plans the page as a parallel walk of the name index, and the workers run far past the 51 rows theLIMITneeds (24k probes). I tried two other shapes: reading the domain's assets first, and a Postgres= ANY(ARRAY(...)). Both fix this cell but make large-domain lists 4–15x slower, so I kept this one. MySQL is not affected (26 → 11 ms). - A large schema whose tables are all outside the picked domain (0 matches) takes about 100 ms at 50k tables, because the whole schema has to be checked. A schema owned by the picked domain has to check each table for a domain of its own (50k tables: 147 ms).
Per-request overhead
- The saved domain is read from the per-user cache that authorization already loads, so a cache hit costs nothing. A cache miss costs one extra query, at most once per user per cache TTL.
- A list with a pick adds one indexed lookup of the domain's sub-domains. It's skipped for excluded types, an explicit
?domain=, bots and personal access tokens. - There's no per-row lookup. The count, page and before/after cursor queries all carry the same condition.
Correctness re-checked on the final build
- Unit tests: 187.
- API checks: 264 (users × roles × picks × lists) plus 30 post-review checks.
- Playwright smoke across the affected pages: 25.
- Default-domain integration tests on MySQL: 6 of 6 pass.
"No domain or a listed domain" was NOT EXISTS ... OR id IN (...). The OR keeps Postgres from planning it as a join, so it hashes every domain link in the database (176k rows in the benchmark) before returning a page, even for a 5k-table schema. A nested NOT EXISTS keeps the same rows and lets Postgres probe per row for a page and join for a count. MySQL already checks the OR per row and is slower with the anti-join on large schemas, so it keeps the existing form.
Performance follow-up:
|
| List, picked domain owns the schema | No pick | Before | After |
|---|---|---|---|
| Schema, 5k tables (typical) | 13 | 131 | 38 |
| Schema, 50k tables | 18 | 160 | 73 |
Every other list in the earlier comment runs SQL this commit doesn't touch. Those moved by up to ±20 ms between runs because the host was shared with other work.
Postgres 15: SQL time, page / count ms (generic plans, warm)
| Schema owned by the picked domain | Before | After |
|---|---|---|
| 5k tables | 45 / 47 | 0.6 / 14 |
| 50k tables | 46 / 61 | 3.8 / 34 |
| 200k tables | 52 / 168 | 5.9 / 69 |
Correctness
- Same rows: the exact matched table ids are identical before and after, across 10 pick × schema combinations. These include tables that have both a selected and a non-selected domain.
UserDAOTest(real Postgres 15 and MySQL 8) adds that mixed-domain case.- Integration tests:
DomainIsolationITandMultiDomainHasDomainITpass 12/12 on Postgres and 12/12 on MySQL. - Unit tests: 171 pass. The build gate passed.
Known cost, not changed here
A large schema where none of the tables are in the picked domain still has to check every table to find out the page is empty. That's about 100 ms at 50k tables and about 30 ms at 5k (13 ms with no pick). The count for this case is fast, so skipping the page query when the count is 0 would remove it. That's a change to the shared list path and has to stay correct when the count is served from cache, so it should be a separate change.
ListFilter picks the MySQL or Postgres form of the domain-access check from DatasourceConfig, which only the server initialises. The test never set it, so the MySQL container ran the Postgres anti-join and the MySQL OR form was never exercised. Point DatasourceConfig at the engine under test; breaking only the MySQL form now fails the three MySQL access cases and none of the Postgres ones.
The eviction ran in deleteChildren through evictNowAndAfterCommit, but the delete path opens no post-commit scope, so both evictions ran immediately, before cleanup() removed and committed the users' DEFAULTS_TO rows. A concurrent read in that gap could re-cache the deleted selection. Evict from DomainRepository.beginDeleteLifecycle instead: the affected users (the domain and its sub-domains, one listSubtreeIds query) are found before anything is deleted, and evicted when the lifecycle closes, after cleanup() commits. The deleted-selection IT now also covers a sub-domain selection.
Queries inherit their domain from their table at read time and have no domain relationship row, so the strict membership match emptied /v1/queries (e.g. the table page's Queries count badge) whenever a domain was selected.
Each navbar domain switch was versioned and emitted entityUpdated events to alerts, webhooks and the feed. It is now stored like lastLoginTime: the selection is saved without a version bump or change event.
…ter needs it Lists naming a parent loaded it on every call with a domain selected, even when the filter didn't apply (e.g. ingestion pipelines listed by service).
- DataQuality "TestCase filters": make the navbar pick as an isolated admin instead of the shared admin, so the saved pick can't narrow concurrent specs. - Glossary, DataProductAndSubdomains, DomainFilterQueryFilter: wait for the PATCH and the reload after a navbar pick before interacting. - Tasks/DomainFiltering: arm the task-count waiter after the save and match the expected domain param, so a leftover count request can't satisfy it. - domain utils: fail fast on a non-ok defaultDomain save; bound the reload wait. - Add a useSwitchActiveDomain unit test (save, clear, failed save, no user).
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
❌ UI Checkstyle Failed❌ Bundle Runtime CheckA route chunk loads but one of its chunks still exports 🔍 ESLint findings in this PR's files — 0 error(s), 34 warning(s)Errors block the build. Warnings do not yet — they are rules whose backlog is still 0 error(s), 34 warning(s) across 9 changed file(s).
All findings
Fix locally (fast - only checks files changed in this branch): make ui-checkstyle-changed |
…ter-persisted # Conflicts: # .github/playwright/impact-map.generated.json
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 9 closed / 9 findings🟡 Medium risk · Persisting defaultDomain and applying it across user-facing list queries could unexpectedly hide assets or distort parent-scoped results across the catalog. Saves the navbar domain pick to the user as ✅ 9 closed✅ Security: Exclusion check bypasses DomainOnlyAccessRole list enforcement
✅ Bug: defaultDomain is never persisted by UserUpdater or evicted from cache
✅ Edge Case: Failed 'All Domains' clear is reverted after navigate(0) reload
✅ Bug: defaultDomain cleared in finally even when the domain delete fails
✅ Bug: Dismissed state is not keyed to entityId and carries over to other entities
...and 4 more closed from earlier reviews VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|



Summary
The navbar domain selector only narrowed search results; REST lists (glossaries, a schema's tables, services, a glossary's terms, …) ignored it, so picking a domain left most pages unfiltered (#31173). This PR saves the pick on the user (
defaultDomain) and applies it server-side to every list endpoint through one central hook, and adds the UI to make the filter visible and reversible.It is a view filter, not access control: lists narrow to the selected domain and its sub-domains, but any asset still opens by URL, lineage or search (with a notice), and RBAC is never weakened.
Addresses #31173 across every list endpoint (supersedes the narrower attempts #31180 and #31538).
Fixes open-metadata/openmetadata-collate#6454
What this PR changes
Backend
User.defaultDomain: the navbar pick, stored as adomain --DEFAULTS_TO--> userrelationship (likedefaultPersona), settable via PATCH and cleared withnull.EntityUtil.addDomainQueryParam(already called by everylistInternal) applies it to the list query.allalias) that support domains; settings/config lists (custom property types, alerts, apps, bots, policies, personas, test definitions) anduser/team/tag/classification/testCaselists are never narrowed.?domain=still wins; bots and internal bulk reads (reindex,listAll) are never narrowed; a domain-only role is only narrowed within its allowed scope, never widened.UI
Screenshots
All with Beta picked in the navbar unless noted (admin user, classic UI).
The original issue
Before this PR, picking Beta still listed every glossary, as in the left image (see #31173).
Browse pages follow the effective (inherited) domain: service → database → schema
Entity page
Glossary term, data products and domains
Explore, Settings, AI mode and the navbar
Videos
Classic UI: pick Beta → glossary list narrows → out-of-domain term and table show the notice (tabs still load) → schema shows the inherited table → Explore with the chip.
demo_classic.webm
AI mode: the same flow through AI mode's domain scope control.
demo_ai.webm
How to review / test
Design and implementation details
Scope: a view filter, not access control
Selecting a domain narrows what lists show. It never blocks a direct read: an entity in another domain still opens by URL, lineage node, or search hit, and the user can switch to any domain. Access control remains entirely with RBAC (
DomainOnlyAccessRole/DomainAccessFilter), which this PR never weakens: a domain-only user is only ever narrowed within their existing scope, never widened.Design
defaultDomain(singleentityReference) on the User schema, stored as adomain --DEFAULTS_TO--> userrelationship (the same pattern asdefaultPersona), not inside the user's JSON. It is a requested field (fields=defaultDomain) and is inSubjectCache.USER_CONTEXT_FIELDS, so the cached subject carries it.UserUpdaterreplaces the row, records the change, and evicts the cached user context immediately and again after commit.JwtFilter(and the no-op / OpenID filters) resolves the caller's persisteddefaultDomainfrom the cached subject and carries it asCatalogSecurityContext.activeDomainplus anActiveDomainContextthread-local, exactly like the active persona. Bots carry none; an impersonated request carries the impersonated user's pick. The list path (EntityUtil.addDomainQueryParam) consumes only that request-carried value and stamps it on theListFilter. Branch order: bots → skip; non-admin withDomainOnlyAccessRole→ the existing enforcement, narrowed to the pick when it is one of the user's allowed domains and never widened; everyone else → the view filter.supportsDomains && isUserFacingData && !DomainFilterExclusions.isExcluded(entityType).supportsDomainsis the entity's intrinsic flag; user-facing data = the type's search index has theallparent alias (so settings/config entities that support domains, e.g. types, alerts, apps, bots, policies, personas, test definitions, doc store, are not narrowed). The exclusion set (user,team,tag,classification,testCase) covers reference/administration lists that must not be emptied.fqnHash, andListFiltermatches againstSELECT id FROM domain_entity WHERE fqnHash = :h OR fqnHash LIKE :h.%, recomputed per call from the live table.?parent=,?databaseSchema=,?service=, …) matches a child by its own domain, else the parent's. The parent is the one the list is already authorized against (ListFilter.getResourceContext/getParentResourceContext; the glossary-term list passes its glossary or parent term), resolved lazily and only when a selection applies. If the parent can't be resolved (or for entity-about lists such as tasks), children are listed in full; a list keyed by several ids is narrowed like an unscoped list.?domain=keeps control. When it only echoes the request's active domain (the UI sends the navbar pick on REST list calls), it is treated as the navbar selection and gets sub-domain matching; any other explicit domain is left exactly as passed.DEFAULTS_TOselection pointing at it.DomainRepositorycollects affected users (oneIN (...)query per 500 deleted domains) and evicts their cached context after the cascade. A selection that doesn't resolve to a live domain is treated as "no selection".Why the auth layer carries it but does not enforce it
The auth layer runs on every request, so it resolves the selection once and makes it available everywhere. Applying it there would block deep-link reads to other domains and empty non-domain lists, so narrowing happens only where list queries are built, with the gating above.
UI details
addupsert on/defaultDomain(first set, change, clear vianull); the app-store user is refreshed from the response, then the page reloads. If the PATCH fails, the navbar shows the error and reverts to the persisted value.?domain=to REST GETs and narrowing/search/query, as on main; searches of theuser,teamandtagindexes (including combined people searches) are not narrowed.searchQuery({ skipDomainFilter: true })marks a request the interceptor must leave alone (used by the asset's data-product picker).DomainMismatchAlert(entity header, glossary header, data product page) shows when the entity's domain is outside the selection (sub-domain aware); dismissal is per entity.DomainFilterChiprenders on the glossary sidebar, Explore and Settings → Services.Tests
DomainNavFilterTest(gating matrix, parent in/outside selection, unresolvable parent, echoed vs explicit domain),EntityUtilTest(addDomainQueryParam_*: view filter for plain user and admin, exclusions, explicit?domain=wins, bots untouched, domain-only role narrowed within scope, stale selection unfiltered, config lists skipped, multi-id lists),ListFilterTest(subtree subquery),JwtFilterTest(selection carried on the security context; bots carry none).UserResourceIT(defaultDomainPATCH round trip, unknown domain rejected, deleting the selected domain doesn't empty lists, glossary terms follow their effective domain).withDomainFilter.test.tsx,searchAPI.test.ts,dataProductAPI.test.ts,useApplicationStore.domain.test.ts,DomainMismatchAlert,DomainFilterChip,DomainFilterUtils,DomainScopeControl,GlossaryLeftPanel,Services,ExploreSearchCard.DomainNavFilter/PersistedDomainFilter.spec.ts(sub-domain inclusion, pick survives reload, clearing restores the list), plus the updatedTasks/DomainFiltering.spec.tsandDomainUIInteractions.spec.ts.CI notes
loginAsIsolatedAdmin) to keep the pick out of parallel workers; navbar helpers wait for the pick to save and the page to reload before the next step.defaultDomainis declaredStoredin the ontology contract, likedefaultPersona.Follow-ups (out of scope)
/tableswithout a parent filter. Parent-scoped lists, which the browse pages use, are covered.listInternal.