Repository navigation
Fixes 30023: apply the caller's policies to bot searches - #32460
Conversation
✅ Playwright Results — workflow succeededValidated commit ✅ 1197 passed · ❌ 0 failed · 🟡 4 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 56m 37s ⏱️ Max setup 4m 34s · max shard execution 18m 34s · max shard-job elapsed before upload 21m 54s · reporting 7s 🌐 240.23 requests/attempt · 2.39 app boots/UI scenario · 27.29% common-shard skew Optimization targets still in progress:
🟡 4 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review ✅ Approved 1 resolved / 1 findingsRemoves the bot exclusion from RBAC policy application in search, fixing search results that were not scoped for bot-authenticated callers. The RBAC query cache key now includes team IDs to prevent stale queries. Comprehensive test coverage confirms bots are now narrowed by their own policies while stock bots remain unaffected with access control enabled. ✅ 1 resolved✅ Bug: RBAC query cache key omits teams, serving stale queries
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #30023 (point 2 only.
semantic_search/ point 1 is separate.)Problem: search ignored the caller's policies whenever the caller was a bot, which is how MCP is normally connected.
search_metadatareturned assets the bot's policies did not allow.SearchUtils.shouldApplyRbacConditions()had a!subjectContext.isBot()check.SubjectContext.isBot()reads theUserrecord'sisBotflag, so any PAT or JWT belonging to a bot user hits it.DomainAccessFilter.shouldApply()had the same check, gating lineage and incident filtering.Fix: removed the
isBotcheck from both, so a bot is policy-evaluated like any other caller.DefaultAuthorizer.authorizealready applied these same policies to a bot's REST reads. Search was the odd one out, so this removes an inconsistency rather than adding a restriction.Impact: none on a default settings.
enableAccessControl,falseby default.DefaultBotRole, whoseDataConsumerPolicygrants an unconditionedViewAllonAll. Allow rules are OR'd, so a stock bot's query still compiles tomatch_all.DomainOnlyAccessRolewas silently doing nothing for bots and now works.governance-botcarries onlyDefaultBotPolicy, so with access control on its searches narrow to the ingestion pipeline index. Governance workflows use the search overload that takes noSubjectContext, so this is not on a live path. Accepted rather than widening the seeded policy.Also in this PR (MCP only):
search_metadatacalledsearchWithDirectQuerywhenever aqueryFilterwas passed. That path never reads the text query or the deleted flag, so both were silently dropped. It now always usessearch().searchWithDirectQueryhas no production caller left; left in place.Two smaller changes: the RBAC query cache key now includes domain and team ids (it keyed on user plus roles only, with a 5 minute TTL and no invalidation, so those changes served a stale query), and two
LOG.infocalls that logged caller query text are nowDEBUG.Type of change:
Tests:
Unit (
openmetadata-service8498 pass,openmetadata-mcp591 pass)SearchUtilsTest,DomainAccessFilterTest,LineageDomainFilterTest. Each failed against the fix before being updated, which is the proof the change bites.BotPolicySearchScopeTest(pins what each seeded bot policy compiles to, so a future seed change fails here instead of in production) andOpenSearchRbacCacheKeyTest.Integration (
DomainIsolationIT, 8 pass)test_assetSearch_botIsNarrowedByItsOwnPolicy,test_assetSearch_stockBotIsUnaffected,test_lineage_restrictedBotSeesOnlyOwnDomainNodes.Verified end to end against a local server, rebuilding only the service jar between runs:
test_assetSearch_botIsNarrowedByItsOwnPolicytest_lineage_restrictedBotSeesOnlyOwnDomainNodesMCP was not driven by hand. The integration test hits the same
SearchRepository.search()entry pointsearch_metadatacalls.Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.