Skip to content

[2.0] Fixes #37164: Only Approved glossary terms can be applied through the API - #37689

Merged
yan-3005 merged 3 commits into
2.0from
backport/2.0/pr-37643
Nov 12, 2026
Merged

yan-3005 merged 3 commits into
2.0from
backport/2.0/pr-37643

Conversation

@yan-3005

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

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #37164

Backport of #37643 to 2.0, for the 2.0.9 release. 2.0 has diverged from main, so this is a hand port, not a cherry-pick. It has the same rule and behaviour: the API rejects, with a 400, any write that newly applies a glossary term that is not Approved. A term that leaves Approved after it was applied stays on the asset, and writes that re-send it still pass.

What differs from main:

  • Finding tagged inline fields. 2.0 has no ChildFieldResolver. EntityRepository.taggedFieldContainers returns nothing by default, and each repository whose entity has tagged inline fields overrides it:
    • columns: Table, DashboardDataModel, Worksheet, File, Container (data-model columns);
    • schema fields: Topic, SearchIndex, APIEndpoint (request and response);
    • Pipeline tasks and ML features. These don't implement FieldInterface on 2.0, so they're wrapped in a small ApprovedGlossaryTermGuard.TaggedField adapter.
  • Glossary term assets/add. The check is in GlossaryTermRepository.bulkAddAndValidateGlossaryToAssets, because 2.0 has no AssetTagLabelService and writes those tags directly.
  • createMany. It's all-or-nothing on 2.0 (no BulkEntityCreator, no onConflict), so a non-Approved term fails the whole request. The IT expects that.
  • Column dry-runs. ColumnRepository predates the CSV-import refactor on main. The search-mode bulk-update dry-run and /bulk-update-preview use the same guard. The CSV dry-run, which already searches once per row, now also checks each row's terms.
  • IT fixtures. 2.0 has no status-fixture glossary that is excluded from the approval workflow. The IT uses plain glossaries, deprecates terms with a status-only PATCH (the workflow doesn't act on those), and gives the draft glossary a reviewer other than the creator, so the workflow can't approve the term on the creator's behalf.

dbt's client-side skip of non-Approved terms is tracked in #37256 and should ship in the same release.

Type of change:

  • Bug fix

Tests:

Run locally on this branch:

  • Unit tests: ApprovedGlossaryTermGuardTest and TagLabelUtilTest. 22 run, 0 failures.
  • GlossaryTermApprovedTaggingIT compiles on 2.0 but hasn't run locally, because Docker stopped responding. It runs in this PR's IT jobs. On 2.0 it covers create, PUT, PATCH, columns, bulk PUT, all-or-nothing createMany, assets/add, dataModel, the column API and preview, File columns, API request fields, container moves, and re-sending held terms.

The first push didn't compile, so 3c8c08172d fixes the 2.0-only differences:

  • EntityInterface isn't generic on 2.0.
  • TagLabelUtil.isSystemGenerated doesn't exist on 2.0, so DERIVED labels are checked inline.
  • Some imports were missing.

The same change passed locally on main (#37643) and 2.1 (#37688): unit tests, the IT, and the impacted Playwright specs.

Checklist:

  • My PR title is [2.0] Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have added tests and listed them above.

🤖 Generated with Claude Code

yan-3005 and others added 2 commits November 12, 2026 18:48
… API (#37643)

* Fixes #37164: Only Approved glossary terms can be applied through the API

The UI only offers Approved glossary terms when tagging an asset, but the
API accepted Draft, In Review, Rejected and Deprecated terms on every write
path. ApprovedGlossaryTermGuard now rejects, per target (asset or inline
field), any glossary term that is newly applied and not Approved: on create,
PUT, PATCH, bulk PUT, the table dataModel, a term's assets/add, the column
API, and the column bulk-update / CSV previews. A term already held on the
same target stays, so writes that carry it back still pass.

* Judge bulk creates per input and match moved fields by name path

createMany runs the glossary-term guard in BulkEntityCreator.prepare so a
rejected input fails alone instead of failing the request. The updater
keys the updated entity's targets by the stored FQN of the same name path,
so a container move that rewrites its data-model column FQNs before the
stored labels are re-keyed does not make a held term look new. Adds tests
for both and for the column bulk-update and CSV dry-run previews.

* Find tagged fields per repository and compare terms by hash

The guard took nested fields from ChildFieldResolver, which leaves File
columns out, and keyed name paths by field name alone, so a request and a
response field with the same name collided. Fields now come from
EntityRepository.taggedFieldContainers (FileRepository adds its columns),
name paths carry the container path and ignore case like column matching,
and terms are compared by FQN hash so a quoted FQN cannot slip past.

* Keep IT fixture names short and record the ingestion decision

The createMany test case's suite is named after its table, so the table
now lives under a short service and schema. The container move test reads
back with tags. The decision record notes that bots get no exemption and
that dbt skips non-Approved terms client-side (#37256), shipping together.

* Test the bulk PUT update rejection and document assets/add

Adds the IT step for a bulk PUT that adds a Deprecated term to an existing
table. assets/add rejects a non-Approved term for every asset in the
request, as the endpoint only applies terms; the Javadoc and ADR now say so.

* Approve the moved term before tagging it in the move-rewrite IT

test_approvedGlossaryTermMoveRewritesTaggedAssetsInSearch tagged a table
with a term still In Review, which is now refused. The test approves the
term through its own approval task first; the aboutEntity filter matches
by FQN prefix, so the task is picked by the term's id, not the first one.

* Judge a column CSV dry-run in one guard call

The dry-run called the approved-term guard once per row, so a file with
many glossary-tagged rows looked terms up row by row on the request thread.
It now pools every row's labels per column, runs the guard once for the
file, and judges each row by its own terms against the shared result.

(cherry picked from commit 9803398)
@yan-3005
yan-3005 requested a review from a team as a code owner November 12, 2026 13:53
@yan-3005
yan-3005 requested review from manerow and removed request for a team November 12, 2026 13:53
@yan-3005 yan-3005 added safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@gitar-bot

gitar-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Gitar is looking for additional findings

Code Review 1 closed / 1 findings
✅ 1 closed
✅ Quality: Misordered imports will fail CI spotless:check

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java:49 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/APIEndpointRepository.java:30 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermApprovedTaggingIT.java:35
The hand port puts import org.openmetadata.schema.FieldInterface; at the top of the non-static import block, ahead of com.fasterxml... / java.util.... This happens in TableRepository, APIEndpointRepository, Container, DashboardDataModel, MlModel, Pipeline, SearchIndex, Topic and Worksheet repositories. The new IT also lists org.openmetadata.it.bootstrap.SharedEntities after the it.factories imports. google-java-format sorts imports in ASCII order, so mvn spotless:check will fail the Java build. The PR says it was never compiled or formatted locally. Fix: run mvn spotless:apply -pl openmetadata-service,openmetadata-integration-tests (or move each import to its sorted position) and commit the result.

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 d545cd9 into 2.0 Nov 12, 2026
59 of 62 checks passed
@yan-3005
yan-3005 deleted the backport/2.0/pr-37643 branch November 12, 2026 14:34
@yan-3005

Copy link
Copy Markdown
Contributor Author

Post-merge check on 2.0 @ 019960d88d, which includes this backport:

  • GlossaryTermApprovedTaggingIT (MySQL + Elasticsearch, run locally): 19 run, 0 failures, BUILD SUCCESS.
  • Collate build against 2.0 with this change: passed.

Dispatched Integration Tests - MySQL + Elasticsearch runs on 2.0 stop before any test with "The build artifact does not match the checked-out commit", even when 2.0 doesn't move during the run. That's a CI problem with workflow_dispatch on 2.0, unrelated to this change.

yan-3005 added a commit that referenced this pull request Nov 17, 2026
…l workflow on 2.0 (#37989)

The 2.0 hand port of #37164 (#37689) created the test's glossaries without
main's status-fixture prefix, and 2.0 had no bootstrap exclusion for it. Each
created term therefore queued a GlossaryTermApprovalWorkflow run; with no
reviewers that run ends in SetGlossaryTermStatusToApproved. When it landed
after the test's status-only deprecate PATCH, the term flipped back to
Approved and the "deprecated term is rejected" assertions got no 400.

Port main's mechanism: GlossaryTestFactory.STATUS_TEST_GLOSSARY_PREFIX /
createForStatusTests, and TestSuiteBootstrap excluding that prefix from the
GlossaryTermApprovalWorkflow trigger before any test runs. The test's
glossaries use the prefix. Test-only; no server change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants