Repository navigation
[2.0] Fixes #37164: Hold glossary terms that are not Approved as pending until approved - #38507
Conversation
…ing until approved Port of #38239 to 2.0. A write that newly applies a glossary term that is not Approved is accepted and the term is held as a pending tag_usage row (internal state 2), hidden from every read, the search index and the change event. When the term is approved, each holding asset gets an ordinary patch by the governance bot (version, change event, cache, search and RDF update); when it is rejected, its pending rows are dropped. 2.0 specifics: the pending layer lives in CollectionDAO.TagUsageDAO; assets/add holds instead of refusing; TaggedField (pipeline tasks, ML features) gets a setter so held terms can be taken out and shown again; assets/remove keeps 2.0's prefix delete and up-front authorization.
❌ 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 |
| dao() | ||
| .listPendingLabels(GLOSSARY, termHash, targets) | ||
| .forEach(row -> labelsByTarget.put(row.getKey(), termLabel(termFqn, row.getValue()))); | ||
| int shown = 0; | ||
| boolean complete = true; | ||
| for (TargetHolder holder : | ||
| labelsByTarget.isEmpty() ? Set.<TargetHolder>of() : holders(targets)) { | ||
| try { | ||
| shown += showOnHolder(termFqn, holder, labelsByTarget); |
There was a problem hiding this comment.
showBatch copies pending labels before editing their assets. If a user calls assets/remove after that copy is loaded, the worker can add the deleted label back. Removal does not change the asset version, so the PATCH's weak ETag still matches.
Check and claim the pending row within the same transaction that applies it, so approval cannot undo a completed removal.
Knowledge Base Used: Metadata entity lifecycle
| */ | ||
| private void flushUpdate(boolean useOptimisticStore, boolean importMode) { | ||
| checkNewlyAppliedGlossaryTermsApproved(); | ||
| List<HeldTerm> heldTerms = holdUnapprovedGlossaryTerms(); |
There was a problem hiding this comment.
The new hold runs after prepareInternal, which already calls checkMutuallyExclusive. A PATCH containing a shown term and a new Draft term from the same mutually exclusive glossary still fails before the Draft term can become pending. The same happens when a Draft term carries a conflicting classification tag.
Separate held terms before checking the labels that will actually be shown. Keep those checks when approval later applies the term.
| feature.getName(), | ||
| feature.getFullyQualifiedName(), | ||
| feature::getTags, | ||
| feature::setTags)) |
There was a problem hiding this comment.
Recreated features receive old terms
Holding terms on ML features creates pending rows that feature deletion never removes. updateMlFeatures collects deletedList but does not clear those features' tag rows. If a feature is deleted and recreated with the same name, approval finds the old pending row by its reused FQN and applies the old term to the new feature.
Delete pending rows when a feature is removed, and test deletion followed by same-name recreation.
Knowledge Base Used: Metadata entity lifecycle
There was a problem hiding this comment.
This one holds on 2.0. Feature tags live in the model JSON, and updateMlFeatures never deletes a removed feature's rows. Main does that in indexTagsOfAddedAndRemovedFeatures (#34816). Porting that cleanup would cover it.
There was a problem hiding this comment.
Got it — that tracks. If indexTagsOfAddedAndRemovedFeatures already handles the cleanup on main, porting that over would close the gap. Without it, the stale pending rows stick around and reattach when a feature with the same name comes back.
There was a problem hiding this comment.
Fixed in 9c2169d: updateMlFeatures now drops the rows of a feature that is gone (matched by name, pending ones included). Ported only the removal half of indexTagsOfAddedAndRemovedFeatures, since 2.0 reads feature tags from the model JSON. removingAnMlFeatureDropsTheTermHeldOnIt (fails without the fix).
| .withTags(List.of(label(term))))); | ||
|
|
||
| assertRejected(() -> client.files().create(request), term); | ||
| org.openmetadata.schema.entity.data.File created = client.files().create(request); |
There was a problem hiding this comment.
The added declaration uses org.openmetadata.schema.entity.data.File inline. The repository's Java guide requires importing classes instead of using fully qualified names in code. Import File and use its short name here before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| entity.verify( | ||
| () -> | ||
| Entity.getEntityByNames( | ||
| Entity.GLOSSARY_TERM, | ||
| List.of(APPROVED.getFullyQualifiedName()), | ||
| "", | ||
| Include.NON_DELETED)); |
There was a problem hiding this comment.
onlyTheNewlyAppliedTermIsLookedUp discards the guard's result and checks only a mocked internal call. The repository guide requires tests to check outcomes rather than internal calls with verify(). This test can pass even when the guard holds the wrong terms.
Assert which terms are held and which stay on the target before merging. Keep call checks secondary. The new anEditApplyingNoNewTermLooksNothingUp test follows the same call-only pattern.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The server holds such a term on the asset until it is approved, so the dbt run succeeds but the term does not show. Log why, and test that a term of every status is still sent. (cherry picked from commit 7ebc479)
There was a problem hiding this comment.
On 2.0 the knowledge page queries are still here in KnowledgePageDAO (lines 16551, 16603 and 16659), not in a separate DAO, so listCount, listBefore and listAfter need tag_usage. + NOT_PENDING on their tagFQN condition, as main has in KnowledgeAssetDAOs. Without it, listing pages filtered by a term returns and counts a page where that term is only pending.
There was a problem hiding this comment.
Fixed in 9c2169d: KnowledgePageDAO listCount, listBefore and listAfter now add tag_usage. + NOT_PENDING to the tagFQN condition, as main does. listingPagesByATermSkipsPagesItIsOnlyPendingOn (fails without the fix).
…n assets/add, drop removed ML features' rows, show terms approved again in a session - KnowledgePageDAO's list and count queries filtered by a term counted a page the term is only pending on. They skip pending rows like every other read. - assets/add held an unapproved term on every target, so the pending write rewrote the type, reason and metadata of a label the asset already shows. It now holds the term only where it is new. - updateMlFeatures never deleted a removed feature's rows, so its pending term passed to a later feature of the same name. They are dropped with it. - Session consolidation rebases the original onto the version before the session, so a term deprecated and approved again by the same user looked unchanged and its held labels stayed hidden. The request's own change now counts as the status change.
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findingsPersisting unapproved glossary labels and asynchronously publishing them on approval changes tag integrity across asset APIs; errors could expose incorrect classifications. Holds glossary terms that are not Approved as pending tag rows instead of applying them, and replays them onto assets once approved. Resolved the issue where ✅ 1 closed✅ Edge Case: assets/add with unapproved term rewrites an already-shown label
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 of #38239 to
2.0(hand port:ClassificationTagDAOs,AssetTagLabelService,BulkEntityCreatorandApprovalGatedo not exist on 2.0). Fixes #37164.What it does (same as #38239)
A write that newly applies a glossary term that is not Approved is accepted, and the term is held as a pending
tag_usagerow (internal state2, not in the publicTagLabel.Stateenum). Pending rows are hidden from every read, the search index and the response. When the term is approved, each holding asset gets an ordinary PATCH bygovernance-bot(version, change event, cache, search, RDF), running as a bounded database task and guarded by the ETag of the version it was built from. A rejected term's pending rows are dropped.GET /v1/glossaryTerms/{id}/pendingAssetslists the holders. The dbt client-side skip (#37571) is reverted, since the server now holds the term.7ebc4790e0c):tag_utils.get_tag_labellogs when it applies a glossary term that is not Approved yet, since the server holds it until approval;test_tag_utils.pychecks a term of every status is still sent.Where 2.0 differs from main
CollectionDAO.TagUsageDAO(MySQL + Postgres SQL), every tag read filtered the same way as main.assets/addnow holds a non-Approved term instead of refusing it.TaggedField(pipeline tasks, ML features, 2.0 only) gets a setter, so a held term can be taken out and shown again on those fields; covered by a new unit test.assets/removekeeps 2.0's own behaviour, unchanged by this port: it authorizes every asset up front (a user who cannot edit the asset gets a 403 for the request) and deletes by FQN prefix, so held labels follow the same rule as shown ones there.ApprovalGateheld-edit checks,ChangeRequestUnapprovedTermIT, the knowledge/ontology DAO filters.Tests (2.0, local)
Tests run: 172, Failures: 0, Errors: 0(incl.ApprovedGlossaryTermGuardTest18 / 0)GlossaryTermApprovedTaggingITTests run: 31, Failures: 0, Errors: 0(main's 32 minus the nested-asset removal test, which does not apply to 2.0's prefix delete)The
To releasebot will also try a[2.0]cherry-pick of #38239 once it merges; that one will conflict and can be closed in favour of this PR.Do not merge until approval cannot undo removals, conflicting Draft labels can become pending, and deleted ML features lose their pending rows.
Findings
Summary
This PR accepts newly applied unapproved glossary terms and stores them as hidden pending labels.
Acknowledged omission:
yan-3005states that knowledge/ontology DAO filters were not ported because they have no 2.0 counterpart.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Asset write with glossary term] --> B{Term approved or already shown?} B -->|Yes| C[Normal asset write] B -->|No| D[Remove label from visible write] D --> E[Store pending tag row] E --> F{Term decision} F -->|Approved| G[Background worker reads holders] G --> H[PATCH each asset as governance-bot] H --> I[Version, event, cache, search and RDF] F -->|Rejected| J[Delete pending rows]Reviews (1) · Last reviewed commit: "[2.0] Fixes #37164: Hold glossary terms ..." · Reviewed by Greptile