Repository navigation
feat: port Metric/MetricGroup read-path relation visibility (upstream PR #36764) - #153
Merged
Merged
Conversation
BMJLearnToHelloWorld
added a commit
that referenced
this pull request
Nov 7, 2026
…-10-31) The two files ported in this PR cite ADR:2026-10-31-metric-and-metric-group-responses-hide-relations-the-viewer-cannot-see in their Javadoc, but the record did not exist in this repo, so the decision-records check in verify-rebuild failed with 2 problems. Add the record (the decision behind #153's REST read-path port, implemented here for the MCP path); the citation now resolves.
BMJLearnToHelloWorld
added a commit
that referenced
this pull request
Nov 7, 2026
…am PR open-metadata#36764 follow-up) (#154) * feat: port MetricRelationVisibility + MCP withVisibleEvidence (upstream PR open-metadata#36764 follow-up) * docs: add ADR record for Metric/MetricGroup relation visibility (2026-10-31) The two files ported in this PR cite ADR:2026-10-31-metric-and-metric-group-responses-hide-relations-the-viewer-cannot-see in their Javadoc, but the record did not exist in this repo, so the decision-records check in verify-rebuild failed with 2 problems. Add the record (the decision behind #153's REST read-path port, implemented here for the MCP path); the citation now resolves. * test(ui): use last-match for UsersListView overflow View item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
范围
移植官方 PR open-metadata#36764(ADR 2026-10-31)的读路径可见性层 + P6 导航栏域 pick:所有携带
Metric/MetricGroup的响应按调用者对被引用实体的ViewBasic权限过滤关系字段并重算派生计数;层级端点加导航栏域 pick 过滤。裁决:~/workspace/work/metric-port/RULING.md(parent idea 复核 APPROVE,2026-11-06 21:55)。背景:#152 的 import 调查发现主干缺的不只是 4 行 import——Wave 0 (g) 移植(
2c1b4626)只落了写路径授权(MetricAuthorization,S4),漏了 PR open-metadata#36764 的整层读路径可见性。本 PR 是 Bai 2026-11-06 20:39 定的“合入后真正修复 import”的实现:移植后MetricResource/MetricGroupResource重新需要那 4 个 import(Map、EntityNotFoundException、AuthorizationException、ResourceContext),不是删掉记残留。10 文件 +1625/−79(base 主干
4ef4fe97):EntityUtil.java:仅navbarDomainIds+navbarDomainMemberIdsMetricRepository.java:sanitizeMetricRelations(×2)+groupInDomainPick(×2)+ 4 处调用点替换 +sanitizeHierarchyMetric扩展MetricGroupRepository.java:MemberVisibility+listMetrics重写 +sanitizeMembership(×2)等MetricResource.java:关系可见性层 + 层级端点三路分支 +hasUnconditionalView改 publicMetricGroupResource.java:成员可见性层 +listMetrics重写MetricResourceIT守卫测试扩展(仅权限部分)对齐程度(逐文件,与官方 pin
a3012259ca全文对照)MetricResource.javacmpIDENTICALMetricGroupResource.javacmpIDENTICALMetricGroupRepository.javacmpIDENTICALMetricRepository.javaEntityUtil.javaMetricResourceTest.javacmpIDENTICALMetricGroupResourceTest.javacmpIDENTICALMetricRepositoryTest.javacmpIDENTICALMetricGroupRepositoryTest.javacmpIDENTICALMetricResourceIT.java替换行逐项列明
裁决 §1.1 文字修正:性质为“官方新增 + 替换”,不是“官方全是新增”。主干独有行(diff 里的
-行)全部是已述的替换,无未交代的主干独有功能:MetricResource.java(12 行):if (canListHierarchyWithoutFiltering(securityContext)) {→ 三路分支(pick 为空且全可见 / 仅 pick 收窄 / pick + 逐实体过滤)。2–3. 两路分支的两个
canAccessEntity谓词(metric / group)→ pick 感知的canViewMetric/canViewGroup(第三路另加groupInPick)。static boolean hasUnconditionalView→public static boolean hasUnconditionalView(为 MCP 消费者准备,无行为变化)。5–12. 8 处调用点裸返回 → 包一层
sanitizeRelations(...):listInternal、get(按 id)、getByName、create(POST)、createOrUpdate(PUT)、updateVoteInternal、restoreEntity;另新增patchInternal×2、delete、deleteByIdAsync、deleteByName4 个 override(主干无此方法,无-行)。MetricGroupResource.java(27 行):import org.openmetadata.schema.type.ResourcePermission;删除——旧listMetrics的残留,官方无此 import。2–4.
listInternal裸返回 → 包sanitizeMembership。5–21. 旧
listMetrics两路分支(17 行:取ResourcePermission→hasUnconditionalView为真调 5 参数重载,否则调 6 参数Predicate重载 →return result)→ 单行repository.listMetrics(id, limit, offset, query, rootOnly, memberVisibility(securityContext))。getByNameInternal裸返回 → 包sanitizeMembership。23–24.
create(POST)/createOrUpdate(PUT)的withoutMembers(create(...))/withoutMembers(createOrUpdate(...))→ 内层包sanitizeMembership。25–26.
delete/deleteByName的withoutMembers(response)→withoutMembers(sanitizeMembership(securityContext, response))。restoreEntity的withoutMembers(restoreEntity(...))→ 内层包sanitizeMembership。(
MetricGroupRepository.java的listMetrics/buildMetricPage重写、MetricRepository.java的调用点替换与sanitizeHierarchyMetric扩展、EntityUtil.java的navbarDomainSearchFilterjavadoc 段落删除——S1 移植注记,主干独有、官方无——亦属替换。)残差(逐行列出,官方行号)
MetricRepository.java(2151 行,与官方差 17 行):bot PUT(裁决 §6.1,不属于权限代码)updateRelatedMetrics内的 bot 分支(三元operation.isPut() && updatedByBot() ? withUnrequestedRelatedMetrics(...) : listOrEmpty(...)+updated.setRelatedMetrics(updatedRelatedMetrics);)。本轮保留主干的单行List<EntityReference> updatedRelatedMetrics = listOrEmpty(updated.getRelatedMetrics());,即 bot PUT 替换 relatedMetrics(与 user PUT 一致)。withUnrequestedRelatedMetrics方法 + javadoc(“A bot PUT adds related metrics and never removes one”,ADR 2026-10-27)。EntityUtil.java(1669 行,与官方差 66 行):两组(裁决 §6.2)sortConstraintPairs组(javadoc :168–173;sortConstraintPairs:174–184;isPairedByPosition:185–187;sortPairsByLocalColumn:189–201;sortIfPresent:203–207)+import java.util.stream.IntStream;(:52)。表约束 FK 列排序,与 metric/权限无关,另立一项。addNavbarDomainFilter(SearchListFilter重载;javadoc :1173;方法 :1174–1193)+import org.openmetadata.service.jdbi3.DomainFilterExclusions;(:79)+import org.openmetadata.service.search.SearchListFilter;(:84)。搜索列表的导航栏域过滤,随 P6 domain navbar 剩余部分另立一项。注意:addNavbarDomainFilter的ListFilter重载(官方 :1142,主干 :1098)是主干已有的,本轮保留——GlossaryTermResource.java:325调用它。MetricResourceIT.java(3732 行,与官方差 123 行):4 个 bot PUT 测试(裁决 §6.1)import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;(仅 bot PUT helper 用)。import org.openmetadata.it.util.BulkApi;(仅 bot PUT 测试用)。put_reingestingRelatedMetricsIsANoOp(@Test:2621)。put_byUserReplacesRelatedMetrics(@Test:2659)。put_byBotNeverRemovesRelatedMetric(@Test:2676)。patch_removesRelatedMetricFromBothSides(@Test:2717)。assertNoRelatedMetricshelper。不移植(本轮,理由见裁决 §6)
sortConstraintPairs/addNavbarDomainFilter(搜索列表)——与 metric/权限无关,另立一项。MetricRelationVisibility+McpMetricRelationVisibilityIT+CommonUtils的 20 行 diff(含 Announcement 两行)——紧随其后的跟进项,不可长期挂起:REST 已过滤后,MCPget_entity_details在跟进项落地前仍返回未过滤的 metric 关系,窗口期内 REST 与 MCP 对同一调用者不一致。relatedMetrics指向权限、按订阅者过滤 change event 读回、/metrics/history与/metricGroups/history的 per-entity/domain 过滤)——官方亦未做,保持“未做”状态,不发明。移植禁区遵守(裁决 §4)
未改动
canAccessEntity/canAccessMetric/MetricAuthorization的判定语义;不可见仍为隐藏(不抛错),referencesOnlyVisibleEntities的判定抛错仍传播;RelationVisibility.unrestricted要求 metrics 与 metric groups 双无条件;canViewBasicfail-closed。移植方向一律是“少给”:任何调用者移植后看到的都不比移植前多;无条件调用者零额外开销(短路、无复制)。门禁
openmetadata-service-unit-tests相关子集 +java-checkstyle+verify-rebuild+maven-sonarcloud-ci:待 CI 回来后填。MetricResourceIT守卫测试在部署后跑(合入后核对)。~/workspace/work/metric-port/IMPLEMENTATION.md(逐文件核对方法、替换行逐项、残差逐行、静态交叉引用核查)。