Fixes #26737: Remove stale dbt automated tags#27368
Fixes #26737: Remove stale dbt automated tags#27368mohitjeswani01 wants to merge 5 commits intoopen-metadata:mainfrom
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
There was a problem hiding this comment.
Pull request overview
Fixes a dbt ingestion edge case where previously-applied AUTOMATED tags from ingestion-bot were not removed from tables/columns when the tags were deleted from dbt schema.yml.
Changes:
- Added DBT-only cleanup in
TableRepository.addDataModelto remove staleAUTOMATEDtags applied byingestion-botat both table and column level. - Added a new unit test class covering stale-tag removal vs. preservation behavior for DBT vs non-DBT models.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java |
Adds DBT-scoped stale automated-tag cleanup during data model application for tables and columns. |
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TableRepositoryDataModelTagTest.java |
Adds tests for the new stale-tag removal logic and related scenarios. |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi @harshach I’ve addressed all feedback from gitar-bot and Copilot (removed the duplicated helper in tests, wired tests to call TableRepository.removeStaleDbtAutomatedTags directly, cleaned up imports, and fixed the Javadoc). Could you please add the |
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
|
Hi @PubChimps 👋 I see Issue #26737 has been closed as completed with my PR #27368 linked. If there are any changes required on my end, please let me know and I'll I'm actively monitoring CI and ready to fix any failures right away on your command.. |
🔴 Playwright Results — 1 failure(s), 23 flaky✅ 3657 passed · ❌ 1 failed · 🟡 23 flaky · ⏭️ 89 skipped
Genuine Failures (failed on all attempts)❌
|
c5198aa to
f3c5f1f
Compare
|
|
||
| static { | ||
| tableRepository = Mockito.mock(TableRepository.class); | ||
| Mockito.when(tableRepository.removeStaleDbtAutomatedTags(Mockito.anyList(), Mockito.anyList())) |
There was a problem hiding this comment.
The Mockito stub uses Mockito.anyList() for incomingTags, which does not match null. In removeStaleDbtAutomatedTags_removesAllDbtAutomatedWhenIncomingNullOrEmpty, dataModel.getTags() is null, so this call won’t hit the thenCallRealMethod() stub and will return the mock default (null), causing an NPE on resultNull.size(). Use a matcher that allows null (e.g., Mockito.nullable(List.class) / Mockito.<List<TagLabel>>any()), or create the mock with CALLS_REAL_METHODS so the real method runs for null inputs too.
| Mockito.when(tableRepository.removeStaleDbtAutomatedTags(Mockito.anyList(), Mockito.anyList())) | |
| Mockito.when( | |
| tableRepository.removeStaleDbtAutomatedTags( | |
| Mockito.anyList(), Mockito.nullable(List.class))) |
There was a problem hiding this comment.
Done. Updated the mock setup to use Mockito.nullable(List.class) to prevent the NPE during null input tests
|
@PubChimps addressed bot comments also ran mvn spotless:apply . please let me know if anything else is needed by my side 🙏 |
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
Code Review ✅ Approved 1 resolved / 1 findingsStale dbt automated tags removed from the codebase. Test coverage now correctly mirrors production logic instead of invoking it directly. ✅ 1 resolved✅ Quality: Test duplicates production logic instead of calling it
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|



Description
Fixes #26737
When dbt removed tags from
schema.yml, the corresponding AUTOMATED tags (labelType=Automated, appliedBy="ingestion-bot") on tables/columns were not getting cleaned up and stayed forever.I changed
TableRepository.addDataModelso that:ingestion-botthat are no longer present in the incoming dbt tags.I also added
TableRepositoryDataModelTagTestto cover the main table/column scenarios and to make sure non‑dbt and non‑ingestion‑bot tags are left untouched.Type of change:
Checklist:
Fixes #26737: Remove stale dbt automated tags