Skip to content

Follow-ups to #36952: query-string field names, team deny-rule cache, closed-team buttons - #37072

Merged
manerow merged 7 commits into
mainfrom
fix/36952-followups
Nov 5, 2026
Merged

manerow merged 7 commits into
mainfrom
fix/36952-followups

Conversation

@manerow

@manerow manerow commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Related: open-metadata/openmetadata-collate#8018

Three small follow-ups to PR #36952, one commit each.

1. Query-string field names are read the way the search engine reads them (PrivateFieldReferences)

The search guard reads the field names in a query string to decide whether a search names a private field. It now resolves escapes in a field name exactly as Lucene's classic query parser does (QueryParserBase.discardEscapeChar), including the four-hex-digit unicode escape. So the name the guard checks is the name the engine searches. A field name with an escape Lucene refuses (truncated or not hex) is treated as naming a private field, the same way the guard already treats DSL it cannot read.

2. The team deny-rule answer expires (RowDecisionGate)

The gate caches, per policy generation, whether any policy attached to a team has a deny rule for a resource. The generation counter lives in each server, and with no cache provider there is no invalidation between servers. So the cached answer now also expires after SubjectCache.POLICIES_TTL (2 minutes), the same bound as the compiled policies it is read beside. A policy change made on one server reaches the listings of the others within that bound, as it already does for item reads.

3. The team page offers joining or leaving a closed team only to admins (TeamDetailsV1)

Since PR #36952, joining or leaving a team that is not joinable is admin-only on the server. The team page already hid "Join team" for such teams, but still showed "Leave team" to every member, and the click failed with a 403. Both buttons now follow the same rule: shown when the team is joinable or the user is an admin.

The three ADRs are updated to match.

Screenshots:

The team page of a Group team that is not joinable, signed in as a member who is not an admin.

Before: the page offers "Leave Team".

1-before

Before: confirming it fails with a 403.

2-before-leave-fails

After: neither "Join Team" nor "Leave Team" is offered.

3-after

Type of change:

  • Bug fix

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests around the new logic.

Tests:

  • PrivateFieldReferencesTest: field names come out with escapes resolved, and refused escapes count as naming a private field. Expected values were checked against Lucene 9.5's QueryParser on the same inputs.
  • RowDecisionGateTest.theTeamDenyAnswerExpiresLikeTheCompiledPolicies: uses a fake ticker.
  • TeamDetailsV1.test.tsx: a non-admin member sees "Leave team" on a joinable team and neither button on a closed one. The closed-team test fails without the change.
  • Ran locally: PrivateFieldReferencesTest, RowDecisionGateTest, PrivateSearchFieldsTest, ElasticSearchPrivateFieldsTest, OpenSearchPrivateFieldsTest, SubjectCacheTest, RBACConditionEvaluatorCacheTest (48 tests), and the TeamDetailsV1 Jest suite (16 tests).
  • Checked in a browser against a server built from this branch, with only TeamDetailsV1.tsx switched back to main for the "before" screenshots.

Summary by Gitar

  • Changed team leave flow:
    • Leaving a team now patches the user's teams via updateUserDetail instead of calling deleteUserFromTeam, and syncs the stored current user.

This will update automatically on new commits.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 17 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 17 warning(s) across 1 changed file(s).

Count Rule
15 react-hooks/exhaustive-deps
2 openmetadata-imports/no-lower-layer-page-imports
All findings
Location Rule Message
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:73:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:74:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:237:5 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:340:5 react-hooks/exhaustive-deps React Hook useCallback has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:562:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'isOrganization'. Either include it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:589:6 react-hooks/exhaustive-deps React Hook useCallback has a missing dependency: 'showModal'. Either include it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:600:6 react-hooks/exhaustive-deps React Hook useCallback has missing dependencies: 'currentTeam.name' and 'navigate'. Either include them or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:639:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:694:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'IMPORT_EXPORT_MENU_ITEM', 'handleOpenToJoinToggle', 'handleReactiveTeam', 'isGroupType', and 't'. Either include t
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:794:6 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 't' and 'teamAssetCounts'. Either include them or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:819:5 react-hooks/exhaustive-deps React Hook useMemo has an unnecessary dependency: 'isTeamMemberLoading'. Either exclude it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:851:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'navigate' and 't'. Either include them or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:930:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'fetchErrorPlaceHolder' and 't'. Either include them or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:1005:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'fetchErrorPlaceHolder' and 't'. Either include them or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:1038:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:1156:5 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'IMPORT_EXPORT_MENU_ITEM' and 't'. Either include them or remove the dependency array. Outer scope values like 'get
🟡 src/components/Settings/Team/TeamDetails/TeamDetailsV1.tsx:1275:5 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 'isGroupType'. Either include it or remove the dependency array.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
81.4% (138468/170091) 68.45% (49896/72886) 71.49% (28043/39222)

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@manerow
manerow enabled auto-merge (squash) November 5, 2026 07:19
… Members tab

The Members tab offered "Leave team" to every member and "Join team" to anyone
with EditAll on the team, but the server lets only admins join or leave a team
that is not joinable. It now follows the same rule as the team page: shown when
the team is joinable or the user is an admin.

Leaving also went through DELETE /teams/{id}/users/{userId}, which needs
EditUsers on the team, so a member who did not own it got a 403 even on a
joinable team. Leaving now patches the user's own teams, as joining does and as
the team page does, and the stored current user is updated from the response so
a join followed by a leave patches from the right team list.
# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/members/MembersTeamDetail.test.tsx
#	openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/members/MembersTeamDetail.tsx
…nt teams

The patch was diffed against the stored current user, whose teams can lag the
server: the user may have been added to the team from the Users tab or another
session. Leaving then sent an empty patch and reported success, or, since the
patch removes by index, could remove a different team. Joining could add at an
index the server's list does not have. The handler now fetches the user's teams
and builds the patch from that copy.
@gitar-bot

gitar-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🔴 High risk · Updating escaped-field checks and team deny-rule caching affects access enforcement; stale or mismatched decisions could expose private fields or denied rows.

Follow-up fixes for team membership handling: the Members tab leave flow now builds its patch from the user's current teams, so a stale store no longer reports false success. No open issues remain.

✅ 1 closed
✅ Edge Case: Leave builds patch from cached user teams; stale store reports false success

📄 openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/members/MembersTeamDetail.tsx:778-792 📄 openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/members/MembersTeamDetail.tsx:811-818
handleLeaveTeam now finds the team to remove in currentUser.teams from the application store. Membership itself comes from team.users (isCurrentUserMember, line 280). These two can disagree. For example, an admin adds themselves through this page's Users tab, or someone adds them in another session. fetchTeam then shows the Leave button, but the store has no entry for this team. The filter removes nothing, compare returns [], and updateUserDetail sends an empty patch. The UI shows 'left team' while the user is still a member. Before this commit, deleteUserFromTeam(team.id, user.id) removed the membership by id whatever the cached state was. Fix: build the patch from a fresh server copy of the user (e.g. getUserById(currentUser.id, { fields: 'teams' })), or bail out with an error when the filtered list is unchanged.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow
manerow merged commit e519ba7 into main Nov 5, 2026
67 of 68 checks passed
@manerow
manerow deleted the fix/36952-followups branch November 5, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants