Repository navigation
fix(mcp): reject get_entity_details without entityType as a 400 (backport 2.0 #36498) - #38160
Conversation
❌ 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 |
Code Review ✅ Approved 🟡 Medium riskRequiring 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 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
On 2.0, calling the MCP tool
get_entity_detailswithoutentityType(and without the batchentitiesparam) throwsNullPointerException: resource is marked non-null but is nullfromOperationContext. 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
GetEntityToolguard never reached 2.0.What changed
GetEntityTool.execute: validateentityType/fqnwith the existingCommonUtils.requireNonBlank, same as main. A missing argument is now anIllegalArgumentException→ 400, logged at WARN byDefaultToolContext.GetEntityToolTest.missingEntityIsRejectedAsABadRequest: the test from fix(mcp): tool error codes and access token revoke #36498.Verification
missingEntityIsRejectedAsABadRequestfailed withNullPointerException: resource is marked non-null but is null(same message as the production error).GetEntityToolTest31/31;spotless:checkclean;openmetadata-mcpbuilds.Details
required: []becauseentities(batch) madeentityType/fqnoptional, so a model can legally send neither. The batch path already validates eachentityType:fqnreference; only the single-entity path was unguarded.CommonUtils.requireNonBlankand the 4xx→WARN logging inDefaultToolContext, so no other part of fix(mcp): tool error codes and access token revoke #36498 is needed for this.The behavior change looks sound; satisfy the Java rule in the new test before merging.
Findings
Summary
The backport checks required arguments before reading a single entity and adds a regression test for the 400 error response.
Reviews (1) · Last reviewed commit: "fix(mcp): reject get_entity_details with..." · Reviewed by Greptile