Repository navigation
Fixes #37164: Hold glossary terms that are not Approved as pending until approved - #38239
Conversation
…til approved A write that newly applies a glossary term that is not Approved no longer fails with a 400. The term is taken out of the write and stored in tag_usage with the new state Pending, which every tag read leaves out: API responses, search documents, caches, counts, the list API tag filter, ontology and knowledge center reads, and CSV export. When the term is approved, its pending rows are flipped in background batches of 500 and every asset holding them is evicted from the cache and reindexed. When it is rejected, they are deleted. Writes that clear and rewrite an asset's tags (CSV import, data model, bulk re-store) keep pending rows. Bulk create and bulk update store them with the entity write, so a failed write leaves none behind. The approval gate no longer refuses such an edit when staging it; the term is held when the approved edit is published. dbt no longer skips terms that are not Approved (reverts #37571); the server holds them. CSV import keeps its per-row refusal.
|
Local run on |
- A batch that fails to show is retried, up to three times, and the holders of a batch are resolved before its rows are flipped. - A write that held a term checks it once the write commits, so a term approved while the write ran is shown. - The server sweeps for pending labels of Approved terms on start. - The holder probe binds at most 20,000 values per query. - Approval and rejection are acted on in GlossaryTermRepository.postUpdate, after the term is stored, bulk updates included. - The approval check for mutual exclusion counts the tags the shown terms imply, fetched once per batch. - Column CSV import keeps refusing a term that is not Approved, in the dry run and the import, as entity CSV import does.
A retry shows nothing for a term deprecated or rejected since its approval. The startup sweep pages through every term with pending labels in FQN order instead of one unordered page.
Pending is appended as ordinal 2, so stored Suggested (0) and Confirmed (1) values keep their meaning.
…ry search
- GET /v1/glossaryTerms/{id}/pendingAssets lists the assets a term's approval
will show it on, page by page.
- A PATCH by the user who applied a pending term that sends a target's labels
without it removes it there. The targets come from the patch paths, so an
edit of another attribute or another field removes nothing. PUT, imports and
other users' writes never remove a pending term. The writer is read before
the flush, which reverts a no-change write to the stored version.
- An asset whose search document fails to index when a term is approved goes
on the search retry queue, so search catches up with the API.
Verification on
|
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.
Code Review ✅ Approved 🔴 High risk 12 closed / 12 findingsThe new tag_usage pending state changes persisted glossary-label lifecycle across entity writes, reads, approval promotion, and rejection deletion; errors could hide or lose labels. Holds newly applied glossary terms that are not yet Approved as pending on assets, showing them once the term is approved and dropping them on rejection. Resolved the bind-limit probe failure, the never-shown pending labels of Approved terms, the PATCH that discarded pending terms, the ADR mismatch, and several approval-pass failure paths. No open findings remain. ✅ 12 closed✅ Bug: holders() probe can exceed the bind limit and stop the approval rollout
✅ Bug: Pending labels of an already-Approved term are never shown
✅ Bug: Schema CSV column import still uses client PATCH and drops pending terms
✅ Edge Case: Adding one tag by PATCH silently discards the user's pending term
✅ Quality: Removal rule contradicts the Accepted ADR, which this PR leaves unamended
...and 7 more closed from earlier reviews 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 |
|
🤖 Not backported to
|
…ing until approved (#38511) * Fixes #37164: Hold glossary terms that are not Approved as pending until approved (#38239) * Fixes #37164: Hold glossary terms that are not Approved as pending until approved A write that newly applies a glossary term that is not Approved no longer fails with a 400. The term is taken out of the write and stored in tag_usage with the new state Pending, which every tag read leaves out: API responses, search documents, caches, counts, the list API tag filter, ontology and knowledge center reads, and CSV export. When the term is approved, its pending rows are flipped in background batches of 500 and every asset holding them is evicted from the cache and reindexed. When it is rejected, they are deleted. Writes that clear and rewrite an asset's tags (CSV import, data model, bulk re-store) keep pending rows. Bulk create and bulk update store them with the entity write, so a failed write leaves none behind. The approval gate no longer refuses such an edit when staging it; the term is held when the approved edit is published. dbt no longer skips terms that are not Approved (reverts #37571); the server holds them. CSV import keeps its per-row refusal. * Recover pending labels of approved terms and keep the column CSV refusal - A batch that fails to show is retried, up to three times, and the holders of a batch are resolved before its rows are flipped. - A write that held a term checks it once the write commits, so a term approved while the write ran is shown. - The server sweeps for pending labels of Approved terms on start. - The holder probe binds at most 20,000 values per query. - Approval and rejection are acted on in GlossaryTermRepository.postUpdate, after the term is stored, bulk updates included. - The approval check for mutual exclusion counts the tags the shown terms imply, fetched once per batch. - Column CSV import keeps refusing a term that is not Approved, in the dry run and the import, as entity CSV import does. * Re-check approval before each retry and page the startup sweep A retry shows nothing for a term deprecated or rejected since its approval. The startup sweep pages through every term with pending labels in FQN order instead of one unordered page. * Count the Pending tag label state in the enum compatibility test Pending is appended as ordinal 2, so stored Suggested (0) and Confirmed (1) values keep their meaning. * Close the review gaps: list pending assets, remove them by PATCH, retry search - GET /v1/glossaryTerms/{id}/pendingAssets lists the assets a term's approval will show it on, page by page. - A PATCH by the user who applied a pending term that sends a target's labels without it removes it there. The targets come from the patch paths, so an edit of another attribute or another field removes nothing. PUT, imports and other users' writes never remove a pending term. The writer is read before the flush, which reverts a no-change write to the stored version. - An asset whose search document fails to index when a term is approved goes on the search retry queue, so search catches up with the API. * Remove pending terms only through assets/remove, filter pendingAssets by view - A write of an asset's labels no longer removes a pending term, by any user: index-level PATCH ops, column inserts and CSV imports made that rule unreliable. The term's assets/remove drops its pending labels on the asset and every field under it. The table CSV import uses the plain PATCH again. - pendingAssets lists only the assets the caller may view. - A data model's held terms record the caller as applier, not the table's previous writer. - The ADR records the endpoint, the removal rule and the search retry. * Authorize and scope pending-term removal through assets/remove - assets/remove authorizes each asset for EditGlossaryTerms before dropping its pending labels, since a pending-only removal patches nothing. - It drops the asset's own pending labels (the entity and its inline fields), not those of other entities nested under its FQN; a column drops its subtree. - Assets are resolved by id, so a reference without an FQN works, and held removals drop pending labels too. * Keep Pending internal and show approved terms through the entity pipeline - Pending is a storage state only the tag DAO knows, one past the public TagLabel.State values, so no client can send or receive it; the public enum and generated models are back to Suggested and Confirmed. - Approval adds the term to each holding asset as an ordinary PATCH by the governance bot, so the asset records a version and a change event and its cache, search document and RDF are updated by the pipeline; the PATCH's upsert turns the pending rows into shown ones. The direct-SQL flip and the hand-made refresh are gone. - assets/remove reports an asset the caller may not edit as failed. * Show an approved term on the targets that take it, keeping what it was sent with - When an asset refuses the term on all its targets at once, as for a mutually exclusive tag on one column, the term is shown on each target alone, so only the refusing targets stay pending. - The term keeps the label type, reason and metadata it was sent with. - A deleted asset is skipped rather than retried. * Keep the approval pass going when an asset's per-target fallback fails The fallback runs inside the per-asset handler, so a failure there marks the pass incomplete and moves on to the next asset instead of ending the pass. * Stop PipelineBulkStatusChangeEventsTest leaving a null repository in Entity's map Stubbing Entity.registerEntity with when(...) on a CALLS_REAL_METHODS static mock runs the real method once with null matchers, which puts a null repository in the process-wide repository map. FqnKeyedRowCleanup iterates that map, so EntityRepositoryRestoreTest's hard-delete tests threw an NPE whenever they ran later in the same fork. The fixture's default answer now skips registration instead. * Hold a term's classifications with it, list only its own assets, keep it across bulk retries - A held term's classification tags were still added as derived labels to the entity the write returns and hands to postCreate. The derived labels only a held term carries are now held with it. - pendingAssets listed every entity above a pending target. It now lists the entity that holds the target, as itself or as one of its fields. - A bulk create retried after a concurrent duplicate reused entities whose held terms had been taken out, and the rollback had dropped their pending rows. A failed chunk gets its terms back before the retry. * Record approval's change event, keep later bulk chunks' terms, list every holding asset - Approval patches each asset from a background job, which has no response for the response filter to record a change event from, so alerts and the activity feed never saw the term arrive. It now records the event itself. - When a bulk create chunk failed, only that chunk got its held terms back, while callers fall back to creating every remaining entity one by one, so the chunks after it were created without their terms. Every chunk from the failed one on gets them back. - pendingAssets kept only the longest matching holder of each target, so an entity whose FQN runs into a held column's (a metric named after it) hid the table. It now keeps a holder when the target is the entity itself or one of its own fields. * Keep held terms on retyped fields and moved containers; page the event check - A column or field whose dataType changes is dropped and re-added under the same FQN, and the unfiltered tag delete also removed the term held on it, so approval never showed it. A field re-added under its name now clears only its shown labels (columns of tables, containers and data models; topic, API endpoint and search index fields). - A container moved to another parent deleted the term held on it. Its pending labels now move to its new FQN. - The approval IT reads every page of change events, since other tests update tables concurrently. * Log when dbt applies a glossary term that is not Approved yet 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. --------- Co-authored-by: ulixius9 <mayursingal9@gmail.com> (cherry picked from commit fb4731f) * Fixes #37164: Show held glossary terms when the same user approves the term again in a session One user's edits to a glossary term within a session are consolidated into one version, and postUpdate then receives the version before the session as the original. A term deprecated and approved again by the same user looked unchanged, so the labels held while it was deprecated stayed hidden until the next restart's sweep. postUpdate now also counts the status as changed when the request's own change description records it. (cherry picked from commit 7f05109) --------- Co-authored-by: Ram Narayan Balaji <81347100+yan-3005@users.noreply.github.com> Co-authored-by: ulixius9 <mayursingal9@gmail.com> Co-authored-by: Ram Narayan Balaji <ramnarayanb3005@gmail.com>
…ing until approved (#38507) * [2.0] Fixes #37164: Hold glossary terms that are not Approved as pending 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. * Log when dbt applies a glossary term that is not Approved yet 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) * [2.0] Skip pending terms in knowledge page lists, keep shown labels on 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. --------- Co-authored-by: ulixius9 <mayursingal9@gmail.com>
Describe your changes:
Fixes #37164 (follow-up to #37643, #37928).
#37643 made the API refuse, with a 400, any write that applies a glossary term that is not Approved. That broke customers who sync terms onto assets as soon as they create them, for example from data products, before a reviewer approves the term. The whole PATCH failed, and nothing applied the term once it was approved.
Now that write succeeds. The term is held back as pending: it's stored but not shown anywhere until the term is approved. On approval it shows up automatically, with no new write. The rule that only Approved terms show on an asset still holds.
pending-glossary-terms-trimmed.mp4
Type of change:
High-level design:
Storage: a
Pendingstate ontag_usage. It's the value 2 in the existingstatecolumn, a storage state only the tag DAO knows (TagUsageDAO.PENDING_STATE). It isn't part of the publicTagLabel.Stateenum, so no client can send or receive it, and the generated models don't change. There's no new table, column, join or migration. A pending row is an ordinarytag_usagerow, so asset, field and term renames, moves and deletes already carry it.Reads. Every tag read skips pending rows through one condition,
TagUsageDAO.NOT_PENDING. That covers entity and column reads (and with them the API, the read caches and search documents), usage counts, the list API's?tags=filter, ontology and knowledge-center reads, and CSV export. On reads it adds only a condition in queries that already run.Writes.
ApprovedGlossaryTermGuard.holdNewlyAppliedtakes each newly applied term that isn't Approved out of the entity being written. Stripping it from the write keeps it out of the diff, change description, response, cache and search document. It's then stored asPendingin the same unit of work as the entity write:EntityUpdater(PATCH, PUT, column API, assets/add)Writes that clear and rewrite an asset's tags (CSV import, data model, bulk re-store) keep pending rows. A client never sees a pending term, so it can't remove one.
Approval.
GlossaryTermRepositoryreacts to the term's status change after commit, throughGlossaryTermPendingLabels:Automatedlabels (what ingestion sends) come backSuggested, any other comes backConfirmed, andappliedBykeeps the original user.GlossaryTermRepository.postUpdate, after the term is stored (bulk updates included).Seeing and removing pending terms:
GET /v1/glossaryTerms/{id}/pendingAssetslists, page by page, the assets a term's approval will show it on.PUT /v1/glossaryTerms/{id}/assets/remove, which drops it on the asset and its own columns or fields (not on other assets nested under it), after checking the caller may edit the asset's glossary terms, or when the term is rejected.pendingAssetslists only assets the caller may view.Search stays consistent: if an asset's search document fails to index after approval, the asset goes on the existing
search_index_retry_queue, andSearchIndexRetryWorkerreindexes it once search is back.Also changed:
ApprovalGateno longer refuses such an edit when staging it (Fixes #37164: Reject non-Approved glossary terms when an approval workflow holds the edit #37928); the term is held when the approved edit is published.2026-11-06-only-approved-glossary-terms-can-be-newly-applied-to-an-assetamended (v3).Not changed / known limits:
Tests:
Unit tests
ApprovedGlossaryTermGuardTestrewritten (18 tests): what is held and what isn't, no lookups when nothing new is applied, read-only tag lists, the state ordinals match the SQL constants.TagLabelUtilTest,ColumnRepositoryImportTest, updated. Local run on59028d19517: 373 tests, 0 failures. CI's full Java unit suite passes onfdb41ddddcf.Backend integration tests
GlossaryTermApprovedTaggingITrewritten from 400 to held, plus approve shows it, reject drops it, writes that replace tags keep it, CSV export and re-import keep it.ChangeRequestUnapprovedTermIT: a held edit is reviewed as usual, and the term is held when it is published.59028d19517: 97 tests, 0 failures (GlossaryTermApprovedTaggingIT,ColumnResourceIT,ChangeRequestUnapprovedTermIT,ChangeRequestImportAndBulkIT).Ingestion
test_dbt.py: this reverts Fixes 37256: Apply only Approved glossary terms from dbt meta #37571's two files exactly. CI's Python unit tests pass onfdb41ddddcf(not run locally; there's no Python environment in this workspace).Live checks (Docker build of this branch)
Test data and timings
Environment: a local Docker build of this branch (MySQL 8, Elasticsearch 9.3.0), with the server heap at 1 GB (
-Xmx1G). Every script below has per-call timeouts and a hard deadline.Live lifecycle check. All 22 steps pass.
pending_svc_<run>, databaseshipping, schemavoyages, tablevessel_voyages_<run>with columnsvoyage_id(BIGINT) andcargo(VARCHAR 50)Shipping_<run>, whose only reviewer is a separate user,maya_<run>, so the approval workflow waits for herLadenVoyage(In Review, later approved by Maya) andBallastVoyage(In Review, later rejected by Maya)LadenVoyageto the table tags and to/columns/1/tags(cargo), sent twicetag_usagestate = 2(Pending); the repeated PATCH leaves 2 rowstags.tagFQN:"<term>"/ the term's Assets liststate = 1; GET shows the term on the table and oncargo; search finds the table; Assets lists it. Shown within ~1 sBallastVoyageheld onvoyage_id, then rejectedLive check of the review fixes (
pending_terms_gaps_live.py). All pass on949718b8923:pendingAssetslists the held table, and is empty once nothing is held./tags, and the applier's own PATCH of the tags all keep the pending rows.assets/removedrops the pending rows on the table and its column.updateEntityIndex: Search client unavailable. After Elasticsearch restarts, the retry worker reindexes it: search finds the table by the term, and the queue row is gone.CSV check (same fixture shape). All 14 steps pass:
Scale test (
pending_terms_scale.py)plain,held,approved)PUT /v1/tables/bulkin requests of 100 tablesHeldTerm(In Review; reviewer is a separate user) on every table and every column ofheld, so 11,000 pending targets; an Approved term onapproved, so 11,000 shown labels as the baselineplain)held)approved)OutOfMemoryErrorThe approval time is the 1,000 ordinary table edits run one after another, each with its version, change event and search update. Scale numbers are from
949718b8923; the bulk-create rows in the Approved-term baseline (11.0 s) are from the earlier run on the same hardware.Automated test runs (local, MySQL + Elasticsearch,
parallellane)GlossaryTermApprovedTaggingITColumnResourceITChangeRequestUnapprovedTermITChangeRequestImportAndBulkITChecklist:
Fixes <issue-number>: <short explanation>docs/decisions/2026-11-06-only-approved-glossary-terms-can-be-newly-applied-to-an-asset.md(v3).Backports: 2.1 and 2.0 once this merges.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with no new actionable issues found.Summary
The PR stores newly applied, unapproved glossary terms as hidden pending labels and publishes them after approval. The latest changes explain that behavior in ingestion logs and test every term status.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Apply glossary term] --> B{Approved?} B -->|Yes| C[Show label] B -->|No| D[Store hidden pending label] D --> E{Term decision} E -->|Approved| F[Patch each holding asset] F --> C E -->|Rejected| G[Delete pending labels]Reviews (21) · Last reviewed commit: "Log when dbt applies a glossary term tha..." · Reviewed by Greptile