Skip to content

Fixes #29510: parse glossary CSV entityStatus case-insensitively#29747

Open
yan-3005 wants to merge 3 commits into
mainfrom
fix/issue-29510-glossary-status-case-insensitive
Open

Fixes #29510: parse glossary CSV entityStatus case-insensitively#29747
yan-3005 wants to merge 3 commits into
mainfrom
fix/issue-29510-glossary-status-case-insensitive

Conversation

@yan-3005

@yan-3005 yan-3005 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #29510.

Glossary and metric CSV imports rejected valid glossaryStatus values whose casing didn't match the JSON-schema enum (Draft, Approved, Deprecated, ...). Users typing draft, APPROVED, or drAFT saw the import fail with Glossary term status <value> is invalid.

  • Add EntityFieldUtils.parseEntityStatus(String) — first tries EntityStatus.fromValue, then falls back to a case-insensitive scan of EntityStatus.values(). Multi-word values (in review, IN REVIEW) match too.
  • Route GlossaryRepository#getTermStatus and MetricRepository#getEntityStatus (both CSV import paths) plus the shared EntityFieldUtils#setEntityStatus through the helper.
  • Invalid values still throw and surface as a clear Field 11 error - Glossary term status <value> is invalid failure row — no silent acceptance.

Test plan

  • Unit: EntityFieldUtilsTest — 15 tests pass. New cases cover Draft / draft / DRAFT / drAFT / DrAfT, approved / APPROVED / ApPrOvEd, Deprecated / deprecated / DEPRECATED, in review / IN REVIEW / In Review, rejected, ARCHIVED, and an unknown-value throws case.
  • Integration: GlossaryResourceIT#test_importCsv_glossaryStatusIsCaseInsensitive — imports terms with draft / APPROVED / deprecated / drAFT; asserts ApiStatus.SUCCESS, 4 rows passed, 0 failed, and terms are created with a non-null entityStatus.
  • Integration: GlossaryResourceIT#test_importCsv_glossaryStatusInvalidValueFails — imports not-a-status; asserts at least one failed row and the message references not-a-status + is invalid.
  • Reviewer: sanity-check that no other CSV importers need the same treatment.

Greptile Summary

This PR makes glossary and metric CSV status imports accept valid status values regardless of case. The main changes are:

  • A shared EntityStatus parser with trimming and case-insensitive matching.
  • Glossary and metric CSV import paths routed through the shared parser.
  • Unit and integration tests for mixed-case valid values and invalid status failures.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java Adds shared case-insensitive parsing for EntityStatus and uses it before the legacy status fallback.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryRepository.java Uses the shared parser for glossary CSV status values while keeping the existing blank default.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MetricRepository.java Uses the shared parser for metric CSV entity status values while keeping blank values unset.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryResourceIT.java Adds glossary CSV import coverage for mixed-case status values and invalid status reporting.
openmetadata-service/src/test/java/org/openmetadata/service/util/EntityFieldUtilsTest.java Adds parser tests for canonical, mixed-case, trimmed, and invalid status inputs.

Reviews (3): Last reviewed commit: "test(glossary): replace ad-hoc Map with ..." | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - openmetadata-ui-core-components/CLAUDE.md (source)
  • Context used - AGENTS.md (source)

Glossary and metric CSV imports rejected valid status values like
`draft` or `APPROVED` because `EntityStatus.fromValue` matches the
enum's canonical casing (`Draft`, `Approved`, ...). Users typing
lower/upper/mixed case saw the import fail with an unhelpful
"status is invalid" error.

Add `EntityFieldUtils.parseEntityStatus` that first tries the exact
enum lookup and falls back to a case-insensitive scan over
`EntityStatus.values()`. Route the glossary and metric CSV importers,
plus the shared `setEntityStatus` helper, through it so any casing
(`draft`, `DRAFT`, `drAFT`, `in review`, ...) resolves to the
canonical enum. Truly unknown values still throw and surface as a
clear per-row validation failure.

Tests:
- EntityFieldUtilsTest: parse helper accepts canonical, lower, upper,
  and mixed casings for every EntityStatus, and throws on unknown
  values.
- GlossaryResourceIT: imports terms with `draft`, `APPROVED`,
  `deprecated`, `drAFT` and asserts the import succeeds and terms
  are created; a second test asserts an invalid value still fails
  with a message referencing the bad input.
Copilot AI review requested due to automatic review settings July 4, 2026 13:10
@yan-3005 yan-3005 added the safe to test Add this label to run secure Github workflows on PRs label Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

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.

Pull request overview

This PR fixes CSV import failures for glossary terms and metrics by parsing EntityStatus case-insensitively, addressing issue #29510 where valid statuses like draft or APPROVED were rejected due to enum casing.

Changes:

  • Added EntityFieldUtils.parseEntityStatus(String) to parse EntityStatus with a case-insensitive fallback.
  • Updated Glossary and Metric CSV import paths to use the new parsing helper.
  • Added unit and integration tests to cover mixed/incorrect casing inputs and invalid-value failures.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java Adds a shared case-insensitive EntityStatus parsing helper and routes setEntityStatus through it.
openmetadata-service/src/test/java/org/openmetadata/service/util/EntityFieldUtilsTest.java Adds unit tests validating mixed-case parsing and unknown-value behavior.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MetricRepository.java Uses the shared parsing helper for metric CSV entityStatus field parsing.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryRepository.java Uses the shared parsing helper for glossary term CSV glossaryStatus parsing.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryResourceIT.java Adds integration coverage for case-insensitive status import and invalid-value failure behavior.

…ow parsing

- parseEntityStatus: single case-insensitive scan over EntityStatus.values()
  after trimming, no more try/catch around EntityStatus.fromValue. Rejects
  null/blank/unknown with a direct IllegalArgumentException.
- Unit tests: cover leading/trailing whitespace ("  draft  ", "Approved\t",
  "\n In Review \n") plus a blank-string throw case.
- GlossaryResourceIT#test_importCsv_glossaryStatusIsCaseInsensitive: assert
  each expected casing ("draft", "APPROVED", "deprecated", "drAFT") appears
  on its own success row in importResult.getImportResultsCsv(). Guards
  against a regression where the importer silently defaults every row to
  the same status.
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (14 flaky)

✅ 4053 passed · ❌ 0 failed · 🟡 14 flaky · ⏭️ 21 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 2 811 0 3 8
🟡 Shard 3 805 0 2 7
🟡 Shard 4 810 0 3 5
✅ Shard 5 859 0 0 0
🟡 Shard 6 768 0 6 1
🟡 14 flaky test(s) (passed on retry)
  • Features/BulkImport.spec.ts › Database Schema (shard 2, 1 retry)
  • Features/ContextCenterPermission.spec.ts › user with deleteAll permission can see delete action but not restore action on an archived document, and can delete it (shard 2, 1 retry)
  • Features/GlobalPageSize.spec.ts › Page size should persist across different pages (shard 2, 2 retries)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 3, 1 retry)
  • Features/SearchExport.spec.ts › Export queues a background job and downloads from the jobs tray (shard 3, 1 retry)
  • Flow/AddRoleAndAssignToUser.spec.ts › Verify assigned role to new user (shard 4, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 4, 1 retry)
  • Pages/CustomProperties.spec.ts › Integer (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel.spec.ts › Should allow Data Steward to edit glossary terms for searchIndex (shard 6, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Import partial success - some terms pass, some fail (shard 6, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Glossary CSV import rejects unknown relation type (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for pipelineService in platform lineage (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for apiService in platform lineage (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

Drop the untyped Map<termName, casing> pair in
test_importCsv_glossaryStatusIsCaseInsensitive in favour of a small
private StatusCase record (termName, displayName, description,
csvCasing). The CSV rows, per-row success assertions, and post-import
lookups now iterate the same typed list, making the test's intent
explicit and removing the Map.of import.
Copilot AI review requested due to automatic review settings July 4, 2026 16:38

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 reached their quota limit.

@gitar-bot

gitar-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Enables case-insensitive parsing for glossary and metric CSV status imports via a new shared utility, ensuring robust validation. No issues found.

Options

Display: compact → Showing less information.

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

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle glossaryStatus Import Case-Insensitively in Glossary CSV Import

2 participants