Skip to content

fix(mcp): reject get_entity_details without entityType as a 400 (backport 2.0 #36498) - #38160

Merged
sonika-shah merged 1 commit into
2.0from
fix/2.0-get-entity-details-missing-entitytype
Nov 19, 2026
Merged

sonika-shah merged 1 commit into
2.0from
fix/2.0-get-entity-details-missing-entitytype

Conversation

@sonika-shah

@sonika-shah sonika-shah commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On 2.0, calling the MCP tool get_entity_details without entityType (and without the batch entities param) throws NullPointerException: resource is marked non-null but is null from OperationContext. It is logged at ERROR and reaches Sentry, and the agent gets an unhelpful error.

Main fixed this in #36498, but the 2.0 backport #36778 carried only the access-token-revoke part, so the GetEntityTool guard never reached 2.0.

What changed

  • GetEntityTool.execute: validate entityType / fqn with the existing CommonUtils.requireNonBlank, same as main. A missing argument is now an IllegalArgumentException → 400, logged at WARN by DefaultToolContext.
  • GetEntityToolTest.missingEntityIsRejectedAsABadRequest: the test from fix(mcp): tool error codes and access token revoke #36498.

Verification

  • RED on 2.0 tip without the fix: missingEntityIsRejectedAsABadRequest failed with NullPointerException: resource is marked non-null but is null (same message as the production error).
  • GREEN with the fix: GetEntityToolTest 31/31; spotless:check clean; openmetadata-mcp builds.
Details
  • The tool schema has required: [] because entities (batch) made entityType/fqn optional, so a model can legally send neither. The batch path already validates each entityType:fqn reference; only the single-entity path was unguarded.
  • 2.0 already has CommonUtils.requireNonBlank and the 4xx→WARN logging in DefaultToolContext, so no other part of fix(mcp): tool error codes and access token revoke #36498 is needed for this.
  • main and 2.1 (from 2.1.0-rc2) already contain the fix.

RetriggerView in GreptileConfidence Score: 4/5

The behavior change looks sound; satisfy the Java rule in the new test before merging.

Findings

  1. P2 `rejected` should be final ▶

Summary

The backport checks required arguments before reading a single entity and adds a regression test for the 400 error response.

  • Single-entity detail calls now require an entity type and name.

Reviews (1) · Last reviewed commit: "fix(mcp): reject get_entity_details with..." · Reviewed by Greptile

…backport 2.0 #36498)

A call with neither a batch nor an entityType reached the
OperationContext constructor with a null resource, so the caller got an
NPE (logged at ERROR) instead of a validation error. Backports the
GetEntityTool guard from #36498, which #36778 did not carry.
@sonika-shah sonika-shah added the safe to test Add this label to run secure Github workflows on PRs label Nov 18, 2026
@github-actions

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.

@gitar-bot

gitar-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Requiring entityType and fqn on single-entity MCP calls changes invalid-request handling; callers omitting either now receive 400 instead of a backend failure.

Adds a validation guard to GetEntityTool.execute so a missing entityType or fqn throws IllegalArgumentException and returns a 400 instead of a NullPointerException, backporting the fix from main to 2.0. No issues found.

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

@sonika-shah
sonika-shah merged commit 8f660be into 2.0 Nov 19, 2026
65 of 77 checks passed
@sonika-shah
sonika-shah deleted the fix/2.0-get-entity-details-missing-entitytype branch November 19, 2026 05:10
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.

2 participants