Repository navigation
Fixes 33460: show metric variants in MCP and keep hierarchy counts in search - #36488
Conversation
…nt recipe, bulk and delete IT, ADR
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · Adding per-variant VIEW_ALL checks before exposing metric SQL changes authorization behavior; a faulty check could disclose restricted expressions in MCP responses. Metric variant SQL is now returned on parent metric reads (capped at 25 visible children), and search hierarchy counts stay accurate across child create, delete, restore and parent edits. Resolved: the new ✅ 2 closed✅ Quality: New search_metadata default fields and reference shape have no record
✅ Quality: Failed variant authorization is swallowed without any log
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 |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
… search (#36488) (#36580) * fix(metrics): show metric variants in mcp and keep hierarchy counts in search * fix cascade restore * fail-closed variant auth, group refresh on restore, metric-only variant recipe, bulk and delete IT, ADR * log failed variant checks, ADR for search fields * cap search metricExpression, cover restore and allowed variant (cherry picked from commit 223a061) Co-authored-by: Vishnu Jain <[email protected]>
Describe your changes:
Fixes #33460
Fixes #34423
get_entity_detailscall per child. A parent read now returns each child's SQL (first 25, only children the caller can view), andsearch_metadatareturnsparent,childrenCountandmetricGroupby default.childrenCountwent stale after a child was created, bulk-created, deleted or restored, and dropped to 0 after a plain edit of the parent. A group'smetricCountdropped to 0 the same way ([Detail Bug] Search API: MetricGroup metricCount becomes 0 in search index after metadata-only edits #34423).NON_DELETED.Type of change:
High-level design:
childrenCount/metricCountare filled in on update before re-indexing. A container that is still deleted is skipped.MetricVariantsadds the expression to each visible child on a parent read. The SQL cap moved toMcpResponseTrim.cappedMetricExpression, shared withsemantic_search. The 25 cap is recorded inADR:2026-10-29-parent-metric-reads-carry-up-to-25-variant-expressions; thesearch_metadatadefault fields, FQN-string shape and cappedmetricExpressioninADR:2026-10-29-search-metadata-hits-show-their-place-in-a-hierarchy.search_metadatahits showparent/childrenCountfor other entity types that have them. Docs indexed before this change stay stale until a reindex.Tests:
Unit tests
SearchMetadataCleanTest#aMetricHitShowsWhereItSitsInTheHierarchy,#aRequestedMetricExpressionIsCappedLikeEveryMetricSummaryopenmetadata-mcp:SearchMetadataCleanTest,SemanticSearchToolTest,GetEntityToolTest,McpSdkUpgradeTest,McpResponseTrimTest: 116 passed.Backend integration tests
MetricGroupResourceIT#searchCountsSurviveChildCreateAndPlainEditsMetricResourceIT#restore_parentWithChildren_bringsTheSubtreeBackAIContextMcpIT#getEntityDetails_parentMetricCarriesEachVariantExpression,#getEntityDetails_withholdsExpressionOfAVariantTheCallerCannotViewNot run locally yet, so this PR stays draft until
make java_affected_runpasses.Manual testing performed
On a local server built from this branch, through REST and the MCP endpoint:
childrenCount/metricCountmatched the real counts after single and bulk create (2 and 26 children), soft delete, restore, hard delete, parent and group edits, and a recursive delete + restore of a parent with 2 children.get_entity_detailson a parent returned each child's SQL; 26 children gave 25 with SQL pluschildrenExpressionsTruncated: true; a non-admin deniedViewAllon one child got that child without SQL and a 403 reading it directly.search_metadatareturnedparent/metricGroupas FQN strings, and theparent.namerecipe listed the variants with their SQL.UI screen recording:
Not applicable: backend and MCP only.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.REVIEW.mdreview of7c4c1be01a1: no 🔴; 🟡 fixed ina2fa46be60a. Not changed: CSV re-import counts (pre-existing, follow-up), per-child authorization (capped at 25), computed-field hydration for every entity (follow-up).ADR:2026-10-29-parent-metric-reads-carry-up-to-25-variant-expressions,ADR:2026-10-29-search-metadata-hits-show-their-place-in-a-hierarchy