Skip to content

Fix MCP entity patch lifecycle handling - #32226

Merged
Vishnuujain merged 7 commits into
mainfrom
codex/fix-mcp-patch-entity-lifecycle
Sep 2, 2026
Merged

Vishnuujain merged 7 commits into
mainfrom
codex/fix-mcp-patch-entity-lifecycle

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #32198

Describe your changes:

Follow-up to #32209.

Make patch_entity authorize with the same PATCH-aware resource context as REST. Reject entity types whose dedicated resource performs additional authorization, scheduling, cleanup, secret handling, or uses a time-series repository, instead of bypassing that lifecycle through a direct repository patch.

Type of change:

  • Bug fix

Tests:

  • PatchEntityToolTest: 28 passed
  • Full openmetadata-mcp suite: 542 passed
  • Maven Spotless check passed

UI screen recording / screenshots:

Not applicable.

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

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

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 60f55803ffbe615e50cee6aef9380b37821de4a5 in Playwright run 33618272601, attempt 1.

✅ 555 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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) 54m 48s

⏱️ Max setup 5m 6s · max shard execution 17m 5s · max shard-job elapsed before upload 20m 6s · reporting 4s

🌐 214.51 requests/attempt · 2.82 app boots/UI scenario · 22.05% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 22.05% (convergence target: at most 15%).
  • Browser traffic was 214.51 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.82 per UI scenario (1627 boots / 576 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 141 0 0 0 0 0
✅ Shard chromium-02 135 0 0 0 0 0
✅ Shard chromium-03 123 0 0 0 0 0
✅ Shard data-asset-rules-01 63 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-01T22:51:04Z)

Blocked the queue: playwright-summary

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-02T05:16:50Z)

Blocked the queue: playwright-summary

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-02T10:10:56Z)

Blocked the queue: playwright-summary

@gitar-bot

gitar-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 resolved / 3 findings

Fixes MCP entity patch lifecycle handling by rejecting entity types whose dedicated resource performs additional authorization, scheduling, or cleanup instead of bypassing that through direct repository patch. Hardcoded lifecycle set and build failure resolved.

Guard uses exact-case string match on entityType — normalize it before the membership check to prevent bypass if a caller supplies differently-cased input like "User" instead of "user".

✅ 3 resolved
✅ Quality: Hardcoded dedicated-lifecycle set can silently drift

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java:49-60
DEDICATED_PATCH_LIFECYCLES is a manually maintained allow/deny list of entity types whose dedicated resource performs extra authorization/scheduling/cleanup/secret handling. When new such entity types are added elsewhere in the codebase, this set will not be updated automatically, so patch_entity would silently bypass their lifecycle again — reintroducing the exact bug this PR fixes. Consider deriving this from a shared source of truth (e.g., a flag/registry on the resource or repository) or adding a test that asserts the list stays in sync, and add a comment pointing maintainers to update it.

✅ Bug: Entity.METRIC_GROUP does not exist — build will fail

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java:77 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java:61 📄 openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/PatchEntityToolTest.java:225
Line 77 adds Entity.METRIC_GROUP to DEDICATED_PATCH_LIFECYCLES, but org.openmetadata.service.Entity (the imported class) defines no METRIC_GROUP constant — only METRIC = "metric" exists, and no metricGroup entity/constant is present anywhere in the repo. This is an unresolved symbol that breaks compilation of the entire openmetadata-mcp module. Remove the Entity.METRIC_GROUP reference (and the corresponding comment line and the metricGroup test ValueSource entry), or add the constant if a metricGroup entity type genuinely exists.

✅ Edge Case: Guard uses exact-case string match on entityType

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/PatchEntityTool.java:114-128
requireGenericPatchLifecycle relies on an exact-case Set.contains check against canonical entity strings (e.g. "user", "app"). If a caller supplies a differently-cased entityType (e.g. "User") that downstream resolution still accepts, the guard is bypassed while the dedicated-lifecycle protection is not applied. Normalize entityType (e.g. lowercase or via Entity's canonicalization) before the membership check, consistent with how the repository lookup resolves the type.

Options

Display: compact → Showing less information.

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

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit ac4a26b Sep 2, 2026
105 of 107 checks passed
@Vishnuujain
Vishnuujain deleted the codex/fix-mcp-patch-entity-lifecycle branch September 2, 2026 22:05
shrabantipaul-collate pushed a commit to PRADDZY/OpenMetadata that referenced this pull request Sep 3, 2026
* fix(mcp): respect entity patch lifecycles

* fix(mcp): protect task patch lifecycle

* gitarbot feedback: block document, metric, metricGroup patch lifecycles too

* reflow lifecycle comment so no entry wraps at the 100-col limit

* drop metric and metricGroup entries, reverted upstream by open-metadata#32333
Vishnuujain added a commit that referenced this pull request Sep 8, 2026
…32342) (#32987)

* Fix MCP entity patch lifecycle handling (#32226)

* fix(mcp): respect entity patch lifecycles

* fix(mcp): protect task patch lifecycle

* gitarbot feedback: block document, metric, metricGroup patch lifecycles too

* reflow lifecycle comment so no entry wraps at the 100-col limit

* drop metric and metricGroup entries, reverted upstream by #32333

(cherry picked from commit ac4a26b)

* feat(search): report embedding token usage instead of discarding it (#32552)

* feat(search): report embedding token usage instead of discarding it

* fix(search): report the text the provider received, not the caller's input

(cherry picked from commit 2209bd7)

* Fixes 30023: apply the caller's policies to bot searches (#32460)

* fix(search): apply the caller's policies to bot searches (#30023)

* test: poll for the widened bot's own view in the allow-only role IT

* test: probe search RBAC on the asset index, not the domain index

* test: prove bot search scoping with a deny rule, not domains

* gitarbot feedback: include team ids in the RBAC query cache key

(cherry picked from commit dda6a92)

* fix(search): embed ElasticSearch semantic search queries as queries, not documents (#32553)

(cherry picked from commit ce2a1c1)

* fix(ingestion): use HTTP transport for MCP connector (#32342)

* fix(ingestion): use HTTP transport for MCP connector

* Update generated TypeScript types and dereferenced schemas

* chore: prune obsolete G004 baseline entries

* fix(ingestion): complete MCP HTTP transport support

* style(ingestion): format MCP transport client

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit c45f71a)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

MCP: prevent patch_entity from bypassing entity patch lifecycles

2 participants