Skip to content

Fixes #37164: Hold glossary terms that are not Approved as pending until approved - #38239

Merged
yan-3005 merged 17 commits into
mainfrom
feature/37164-pending-glossary-terms
Nov 23, 2026
Merged

yan-3005 merged 17 commits into
mainfrom
feature/37164-pending-glossary-terms

Conversation

@yan-3005

@yan-3005 yan-3005 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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.

Table page before and after approval

pending-glossary-terms-trimmed.mp4

Type of change:

  • Bug fix

High-level design:

Storage: a Pending state on tag_usage. It's the value 2 in the existing state column, a storage state only the tag DAO knows (TagUsageDAO.PENDING_STATE). It isn't part of the public TagLabel.State enum, 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 ordinary tag_usage row, 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.holdNewlyApplied takes 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 as Pending in the same unit of work as the entity write:

  • the single create, and bulk create per chunk
  • EntityUpdater (PATCH, PUT, column API, assets/add)
  • bulk update, only after the entity row is written
  • table data model, after the row is written

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. GlossaryTermRepository reacts to the term's status change after commit, through GlossaryTermPendingLabels:

  • Approved:
    • In batches of 500 pending targets, each holding asset gets the term through an ordinary PATCH by the governance bot. The asset records a version and a change event, and the pipeline updates its cache, search document and RDF; a failed search update goes on the search retry queue.
    • The PATCH's upsert turns the pending rows into shown ones: Automated labels (what ingestion sends) come back Suggested, any other comes back Confirmed, and appliedBy keeps the original user.
    • A PATCH the pipeline refuses, such as a mutual-exclusion conflict, leaves that asset pending.
  • Rejected: pending rows are deleted.
  • These run in GlossaryTermRepository.postUpdate, after the term is stored (bulk updates included).
  • Recovery: a failed batch is retried, up to 3 times. A write that held a term re-checks it after commit, so an approval racing the write isn't missed. The server sweeps on start for pending labels of Approved terms.

Seeing and removing pending terms:

  • GET /v1/glossaryTerms/{id}/pendingAssets lists, page by page, the assets a term's approval will show it on.
  • A pending term isn't shown, so no write of an asset's labels removes it, by any user. It's removed through the term's 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. pendingAssets lists 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, and SearchIndexRetryWorker reindexes it once search is back.

Also changed:

Not changed / known limits:

  • No UI for pending assets yet; the API above lists them.
  • Terms already on assets before this change are left as they are.

Tests:

Unit tests

  • ApprovedGlossaryTermGuardTest rewritten (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 on 59028d19517: 373 tests, 0 failures. CI's full Java unit suite passes on fdb41ddddcf.

Backend integration tests

  • GlossaryTermApprovedTaggingIT rewritten 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.
  • Local, MySQL + Elasticsearch, on 59028d19517: 97 tests, 0 failures (GlossaryTermApprovedTaggingIT, ColumnResourceIT, ChangeRequestUnapprovedTermIT, ChangeRequestImportAndBulkIT).

Ingestion

Live checks (Docker build of this branch)

  • Lifecycle: PATCH 200 → term hidden in the response, GET, search and the term's Assets → 2 rows Pending → the reviewer approves → shown everywhere, rows Confirmed. Reject drops the pending rows. A repeated sync stays at one row per target.
  • CSV: table and schema exports leave the term out. Re-importing them keeps it held. A CSV naming an In Review term fails that row. After approval, the export includes it.

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.

Data What was created
Asset Database service pending_svc_<run>, database shipping, schema voyages, table vessel_voyages_<run> with columns voyage_id (BIGINT) and cargo (VARCHAR 50)
Glossary Shipping_<run>, whose only reviewer is a separate user, maya_<run>, so the approval workflow waits for her
Terms LadenVoyage (In Review, later approved by Maya) and BallastVoyage (In Review, later rejected by Maya)
Write One JSON PATCH adding LadenVoyage to the table tags and to /columns/1/tags (cargo), sent twice
Step Result
PATCH with the In Review term 200; the term is in neither the response nor GET
tag_usage 2 rows, state = 2 (Pending); the repeated PATCH leaves 2 rows
Search tags.tagFQN:"<term>" / the term's Assets list 0 hits / empty
Maya approves through her review task term Approved; both rows state = 1; GET shows the term on the table and on cargo; search finds the table; Assets lists it. Shown within ~1 s
BallastVoyage held on voyage_id, then rejected pending row deleted; never shown

Live check of the review fixes (pending_terms_gaps_live.py). All pass on 949718b8923:

  • pendingAssets lists the held table, and is empty once nothing is held.
  • Description-only PATCHes, another user's PATCH of /tags, and the applier's own PATCH of the tags all keep the pending rows.
  • assets/remove drops the pending rows on the table and its column.
  • Search outage (Elasticsearch stopped): the reviewer approves, and the rows still flip to Confirmed. The table is queued for search retry with reason 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:

  • the table and schema CSV exports leave the term out;
  • re-importing them unchanged succeeds and keeps both pending rows;
  • a CSV naming the In Review term fails that row ("must have APPROVED status") and adds nothing;
  • after approval, the export includes the term.

Scale test (pending_terms_scale.py)

Data What was created
Asset 1 service, 1 database, 3 schemas (plain, held, approved)
Tables 1,000 per schema, each with 10 VARCHAR columns, written with PUT /v1/tables/bulk in requests of 100 tables
Terms HeldTerm (In Review; reviewer is a separate user) on every table and every column of held, so 11,000 pending targets; an Approved term on approved, so 11,000 shown labels as the baseline
Measure Time / value
Bulk create of 1,000 tables, no tags (plain) 5.7 s, 0 failures
Bulk create of 1,000 tables, held term (held) 14.9 s, 0 failures
Bulk create of 1,000 tables, Approved term (approved) 11.0 s, 0 failures; holding costs nothing extra over writing the same labels
Before approval 11,000 rows Pending, 0 shown, 0 search hits
Approval → all 11,000 rows shown 107.1 s, in the background: 1,000 table PATCHes by the governance bot, each with a version and change event
Approval → search returns all 1,000 tables 107.2 s
Heap during approval 443 MB baseline, 495 MB peak of 1,074 MB; no OutOfMemoryError
After 11,000 rows Confirmed, 0 Pending, 1,000 search hits; a sample table shows the term on the table and all 10 columns; server healthy

The 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, parallel lane)

Suite Tests Time
GlossaryTermApprovedTaggingIT 35 / 0 failures 18.1 s
ColumnResourceIT 51 / 0 failures 30.4 s
ChangeRequestUnapprovedTermIT 5 / 0 failures 13.9 s
ChangeRequestImportAndBulkIT 10 / 0 failures 11.2 s
Unit tests (impacted classes) 403 / 0 failures about 1 min

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added a test that covers the exact scenario we are fixing.
  • Decision check: amends 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

RetriggerView in GreptileConfidence 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.

  • Asset writes keep non-approved glossary terms pending until they are approved.
  • Pending glossary terms stay out of tag reads and survive tag rewrites.
  • Approval shows held terms on their assets, while rejection removes them.

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]
Loading

Reviews (21) · Last reviewed commit: "Log when dbt applies a glossary term tha..." · Reviewed by Greptile

…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.
@yan-3005
yan-3005 requested review from a team as code owners November 19, 2026 18:41
@yan-3005
yan-3005 requested a review from Khairajani November 19, 2026 18:41
@yan-3005 yan-3005 added the To release Will cherry-pick this PR into the release branch label Nov 19, 2026
@yan-3005
yan-3005 requested review from harshach and a balanced review from Copilot November 19, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@yan-3005

Copy link
Copy Markdown
Contributor Author

Local run on 424ad3a133f (MySQL + Elasticsearch, parallel lane): GlossaryTermApprovedTaggingIT ran 23 tests with 0 failures, including the new csvExportAndReimportKeepTheHeldTerm.

- 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.
Copilot AI balanced review requested due to automatic review settings November 19, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.
Copilot AI balanced review requested due to automatic review settings November 19, 2026 19:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Pending is appended as ordinal 2, so stored Suggested (0) and Confirmed (1) values keep their meaning.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…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.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@yan-3005

Copy link
Copy Markdown
Contributor Author

Verification on e3c8fd2cc30 (main merged + latest review fixes)

Playwright, full suite (run 45167926968, Postgres, dispatched on this branch): 5,063 passed, 0 failed, 1 flaky (AddTestCaseNewFlow.spec.ts:352, data quality, passed on retry), 1 skipped.

Integration tests (local, MySQL + Elasticsearch):

Unit tests: 148 / 0

Live server on this revision: 44 / 44 checks pass

  • Unapproved term: PATCH answers 200; GET, search and the term's assets do not show it; pending rows in tag_usage; approval shows it in GET and search; rejection drops it.
  • A term's classification stays hidden while it is held; a retyped column and a moved container keep their held term; pendingAssets lists the holding assets only; approval records a change event per asset as governance-bot, running on the bounded database executor with the ETag-guarded patch.

Collate companion: https://github.com/open-metadata/openmetadata-collate/pull/8881

harshsoni2024
harshsoni2024 previously approved these changes Nov 23, 2026
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.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 12 closed / 12 findings

The 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

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermPendingLabels.java:92-99 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermPendingLabels.java:121-135 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationTagDAOs.java:722-725
holders() puts every target hash and each of its proper prefixes into one IN list, then repeats that list in a UNION ALL probe for each taggable entity table (about 60 entity schemas carry tags). JDBI turns each :hN occurrence into its own positional ?. A batch of 500 targets spread over different tables and schemas yields 1,500+ distinct hashes, and multiplied by the table count that passes the 65,535-parameter limit of the Postgres protocol/pgjdbc. The statement also gets very large on MySQL.

holders() is called outside the per-holder try/catch. If it throws, showBatch has already committed confirmPending for that batch, but those entities are never evicted from cache or reindexed. The exception then escapes applyApproved and showWhenApproved only logs it, so every later batch stays pending for good.

Fix: bound the probe by chunking the hashes in holders() so hashes.size() * tables stays well below the limit. Alternatively, group targets by entity first so you only probe the prefix that can be an entity. Also catch failures per batch so one bad refresh does not stop the loop.

✅ Bug: Pending labels of an already-Approved term are never shown

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermPendingLabels.java:36-43 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermPendingLabels.java:52-64 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermRepository.java:2607-2617 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:6480-6487 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:11347-11357
The class Javadoc says a crash leaves the remaining labels pending "and applyApproved picks them up again". But the only caller of applyApproved is showWhenApproved, and it runs once, from settlePendingLabels, when the status changes to APPROVED. Nothing runs it again on startup, from a scheduled job, or on a later write. These cases all leave pending rows on an Approved term for good:

  1. The server restarts while the async task is queued or running on AsyncService.
  2. applyApproved throws (see the holders() finding). showWhenApproved only logs the error.
  3. A write races the approval. The guard reads the term as Draft and holds it. The approval commits and its background pass finishes. Then the write commits its PENDING row. The term is now Approved, so no transition ever re-runs the pass.

The tree has no UI or API to see or clear these rows, so the asset silently never shows the term, even though the description says approval shows it "automatically with no new write".

Fix: make the pass recoverable. One option is a startup or periodic sweep that runs applyApproved for Approved terms that still have pending rows. Another is to have storePendingGlossaryTerms re-check the term status after its insert, and confirm right away if the term is Approved by then. Also correct the Javadoc so it does not claim recovery that doesn't exist.

✅ Bug: Schema CSV column import still uses client PATCH and drops pending terms

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:5171-5173 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:6576-6585 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java:2717-2720
This commit moves TableRepository.TableCsv.patchColumns to patchForImport so that a CSV import never removes a pending term. The other column-import path, EntityCsv.flushPendingTableUpdates (EntityCsv.java:2433-2436, which batches column rows from a database or schema CSV), still calls tableRepo.patch(null, id, importedBy, jsonPatch). That call computes labelTargetsSent. The export leaves pending terms out, so a re-import by the user who applied a term, where the file changes any tag on that column, makes replacePendingGlossaryTerms delete that user's pending row. This breaks the documented rule that "PUT, CSV import ... never remove a pending term". Fix: call patchForImport there as well, and add an IT that re-imports a schema CSV with a changed column tag.

✅ Edge Case: Adding one tag by PATCH silently discards the user's pending term

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ApprovedGlossaryTermGuard.java:150-164 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:6576-6585 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:11434
targetsSent counts any path under a target's tags (for example add /tags/1) as sending that target's whole label list. replacePendingGlossaryTerms then deletes every pending row the writer holds on that target. A JSON Patch add or remove at an index is incremental and does not claim to send the full list. Because a pending term is never shown, a user who later adds an unrelated Approved tag to the same asset or column in the UI loses their held term without being told, and it never appears on approval. The same happens to an ingestion bot whose next patch only adds a different tag. Fix: remove pending terms only when a patch replaces the whole list (replace/add at /tags or <field>/tags, or a replace of the containing field), or only on an explicit remove request, not on index-level ops.

✅ Quality: Removal rule contradicts the Accepted ADR, which this PR leaves unamended

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:6569-6583 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/glossary/GlossaryTermResource.java:1144-1158 📄 docs/decisions/2026-11-06-only-approved-glossary-terms-can-be-newly-applied-to-an-asset.md
ADR 2026-11-06-only-approved-glossary-terms-can-be-newly-applied-to-an-asset (Amendment section) says: "a client never sees a pending term, so it cannot remove one." This commit adds exactly that ability: a PATCH by the user in appliedBy that sends a target's labels deletes their pending rows there (replacePendingGlossaryTerms, deletePendingAppliedBy). It also adds a new REST contract, GET /v1/glossaryTerms/{id}/pendingAssets, whose cursor is a target FQN hash, and the ADR does not record it. Amend the ADR to state the rules from the description: "A pending term is removed only by a PATCH from the user who applied it that sends the target's labels without it; PUT, CSV import and other users' writes never remove one," and "GET /v1/glossaryTerms/{id}/pendingAssets lists the assets holding a term's pending targets, paged by an after cursor over target hashes."

...and 7 more closed from earlier reviews

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@yan-3005
yan-3005 merged commit fb4731f into main Nov 23, 2026
60 checks passed
@yan-3005
yan-3005 deleted the feature/37164-pending-glossary-terms branch November 23, 2026 15:27
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #38511. Claude resolved a cherry-pick conflict to build it. It merges itself once the checks pass, so read the diff now if this change is a sensitive one.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Not backported to 2.0. Claude looked at the conflict and declined to resolve it:

Backport aborted: PR #38239 (fb4731f) → 2.0

Reason

This PR's entire feature — holding non-Approved glossary terms as "Pending"
instead of rejecting the write — is built directly on top of a separate
governance/approval framework for entity edits that does not exist on the
2.0 branch:

  • org.openmetadata.service.governance.approval.ApprovalGate — the whole
    governance/approval package is absent from 2.0. The PR's core logic in
    EntityRepository.java (the base class every entity repository extends)
    calls ApprovalGate.preview(...), ApprovalGate.admit(...),
    ApprovalGate.verifyApproved(...), and ApprovalGate.mayHold(...) as part
    of the normal create/update lifecycle. None of these hooks, nor the
    "change request" concept they gate, exist on 2.0.
  • ChangeRequestUnapprovedTermIT.java — a new integration test exercising
    the interaction between this feature and the change-request approval
    workflow, which itself has no counterpart on 2.0.
  • OntologyDAO.java and AssetTagLabelService.java — GlossaryTermRepository
    on main now depends on both directly (ontology lineage/term-asset-count
    queries, and the asset-tag-label plumbing used to add/remove pending terms
    from assets). Neither file exists on 2.0.
  • ClassificationTagDAOs.java, KnowledgeAssetDAOs.java,
    BulkEntityCreator.java — further supporting DAOs/services this PR's
    conflicted files (ApprovedGlossaryTermGuardTest.java,
    EntityRepository.java) reference, also absent from 2.0.

In short: 2.0 predates whatever PR(s) introduced the change-request /
approval-gate governance system, the ontology DAO, and the bulk entity
creator. Porting "hold pending glossary terms until approved" would first
require backporting that entire prerequisite architecture — a large, separate
effort, not something that can be "sensibly adapted" into this conflict
resolution. Forcing a resolution here (e.g. stripping the ApprovalGate
integration) would silently drop the mutual-exclusion/approval-gate
interaction the source PR explicitly added, which is exactly the kind of
silent failure this workflow exists to avoid.

Recommendation

Do not backport #38239 to 2.0 until the underlying change-request /
approval-gate governance feature (and the OntologyDAO /
AssetTagLabelService / BulkEntityCreator infrastructure it depends on) is
backported first. At that point this PR could be reconsidered as a follow-up
backport.

State left behind

The repository is left mid-cherry-pick (git cherry-pick -x fb4731f0adbab92df9d80236735bb1bd95014ba2 with unresolved conflicts), exactly
as it was handed to this step. No files were edited, staged, or committed.

resolver run

yan-3005 added a commit that referenced this pull request Nov 24, 2026
…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>
yan-3005 added a commit that referenced this pull request Nov 24, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Enforce consistent glossary term tagging rules between API and UI

5 participants