Repository navigation
Fixes #38346: check derived FQN across all entity tables before moving tags - #38383
Conversation
…-across-all-entity-ta-118f03
| void aGlossaryTermNamedLikeTheFileKeepsEveryTagRowUnderTheBareName(TestNamespace ns) { | ||
| String folderName = ns.shortPrefix("Y"); | ||
| String name = ns.shortPrefix("x"); | ||
| Glossary glossary = | ||
| ns.trackRoot( | ||
| Entity.GLOSSARY, | ||
| SdkClients.adminClient() | ||
| .getHttpClient() | ||
| .execute( | ||
| HttpMethod.POST, | ||
| GLOSSARIES, | ||
| new CreateGlossary() | ||
| .withName(folderName) | ||
| .withDescription("Named like the file's folder"), | ||
| Glossary.class)); |
There was a problem hiding this comment.
Collision methods are too long
The new glossary-term test has roughly 40 nonblank lines. The Java guide requires methods to stay around 15 lines and do one named thing. Extract the fixture setup and shared assertions into helpers. The new subfolder test and expanded repair method also exceed this limit. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Addressed in e548996: extracted the two collision LOG.warn blocks into a logCollisions helper, and extracted the glossary-term/subfolder fixture setup (createGlossary, createGlossaryTerm, glossaryTermNamedLikeTheFile) and shared after-repair assertions (assertTagsStayUnderTheirOwner) so each new test and repair stay short and do one named thing.
|
Verified locally (MySQL + Elasticsearch, parallel lane):
Note for reviewers: this edits the v210 |
- Extract the two collision LOG.warn blocks in ContextFileFqnRepair.repair into a logCollisions helper so the method stays short and does one thing. - Extract fixture setup (createGlossary, createGlossaryTerm, glossaryTermNamedLikeTheFile) and shared after-repair assertions (assertTagsStayUnderTheirOwner) so each new test stays short. - Register the new Context Center files with TestNamespace and add an @AfterEach that deletes the folders the new tests create (folders are not in TestNamespaceExtension's cleanup map), so runs leave no fixtures behind.
| } catch (RuntimeException ignored) { | ||
| // Best-effort, like NamespaceCleanup: a failed delete never fails a green test. | ||
| } |
There was a problem hiding this comment.
deleteFolders silently catches every RuntimeException. The Java guide requires catch blocks to log failures at minimum. Log the folder ID and exception so failed cleanup leaves an explanation. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| private static void assertTagsStayUnderTheirOwner( | ||
| ContextFile file, | ||
| String derivedFqn, | ||
| List<String> otherTagsBefore, | ||
| Supplier<List<String>> otherTagsAfter, | ||
| String bareName, | ||
| int rowsUnderBareName) { |
There was a problem hiding this comment.
Helper exceeds the parameter limit
assertTagsStayUnderTheirOwner takes six parameters. The Java guide allows at most five and requires related values to travel in a record or parameter object. Group the fixture details before passing them to this helper. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| private static Glossary createGlossary( | ||
| TestNamespace ns, String name, String description, String... tags) { | ||
| CreateGlossary request = new CreateGlossary().withName(name).withDescription(description); |
There was a problem hiding this comment.
The new test helpers omit final from parameters and locals that never change. The Java guide requires final on those values. Apply it in createGlossary, createGlossaryTerm, and the other new helpers, including assertTagsStayUnderTheirOwner. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
yan-3005
left a comment
There was a problem hiding this comment.
Verified: ContextFileFqnRepairMigrationIT collision cases fail on main (file tags merge into the same-named glossary term/subfolder) and pass 4/4 with this fix. Latest commit is a behavior-neutral helper extraction + fixture cleanup.
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Not backported to
|
…g tags (#38383) (#38513) * fix(migration): check derived FQN across all entity tables before moving tags * Address review: extract helpers, register fixtures for cleanup - Extract the two collision LOG.warn blocks in ContextFileFqnRepair.repair into a logCollisions helper so the method stays short and does one thing. - Extract fixture setup (createGlossary, createGlossaryTerm, glossaryTermNamedLikeTheFile) and shared after-repair assertions (assertTagsStayUnderTheirOwner) so each new test stays short. - Register the new Context Center files with TestNamespace and add an @AfterEach that deletes the folders the new tests create (folders are not in TestNamespaceExtension's cleanup map), so runs leave no fixtures behind. --------- (cherry picked from commit 585284f) Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com> Co-authored-by: Ram Narayan Balaji <[email protected]>
Detail bug report: View on Detail
Describe your changes:
Fixes #38346
I worked on the 2.1.0
ContextFileFqnRepairmigration because itstag_usagecollision guards were asymmetric and could silently merge one entity's tags onto another unrelated entity at upgrade time.tag_usagerows to the derived FQN's hash. Before moving, it scanned the stored FQN across every registered entity table (and skipped the move + logged if another entity owned it), but checked the derived FQN only against othercontext_filerows. When a non-file entity (a subfolder, glossary term, subdomain, … with FQNparentFQN + "." + name) already held the derived FQN, the migration moved the file's rows onto that hash anyway.tag_usageis keyed by FQN hash alone with no owner, so the two entities' rows merged: the co-tenant started displaying the file's tags (and the file the co-tenant's), and a tag they shared had the file's stored-side row deleted outright. The migration isrunOnce, so this was never retried or re-evaluated.repair(...)now runsEntityFqnHolders.holding(...)(the all-entity scan) for both the stored and the derived FQN, andmoveTagsruns only when both return no non-context_fileholder. When a non-file entity holds the derived FQN, the file's FQN andnameHashare still repaired (the rename is safe —context_file.nameHashis unique per table), but the tag rows are left under the bare-name hash and the file, both FQNs, and the co-tenant are logged for hand repair — exactly as the stored-side branch already did. TheentitiesSharinghelper was generalized from(holders, misnamed)to(holders, fqn, id)and is called for both FQNs. The class javadoc was updated to describe the symmetric policy.Type of change:
High-level design:
N/A — small change. The fix mirrors the migration's own stored-side collision policy onto the derived side, using the existing
EntityFqnHoldersall-entity scan that already runs for the stored FQN. No new tables, no schema change, no migration version bump — therunOncestep's logic is corrected.Tests:
Use cases covered
tag_usagerow moves or is deleted (the new derived-side cross-type collision case from the bug report).context_file+folderonly).Unit tests
ContextFileFqnRepair.repairAllis mocked at the v210 entry point (IngestionPipelineMigrationEntryPointTest); its public signature is unchanged and that test still passes (2/2). The repair behaviour is exercised by the integration tests below.Backend integration tests
openmetadata-integration-tests/for the changed migration logic.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ContextFileFqnRepairMigrationIT.java(2 new tests:aSubfolderNamedLikeTheFileUnderTheSameParentKeepsEveryTagRowUnderTheBareName,aGlossaryTermNamedLikeTheFileKeepsEveryTagRowUnderTheBareName; plus acreateFolder(name, parent, tags...)helper overload and aglossaryTermTagshelper).repairAllis invoked throughTestSuiteBootstrap.getJdbi(), and assertions hit both the REST API (?fields=tags) andtag_usagerow counts by FQN hash).PR checks run only the Java unit tests; the integration tests run in the merge queue and JavaUIIT / search-it nightly. For PR creation, record focused checks and list broader checks as pending. Merge readiness
requires the full impacted plan. Tests are selected from
.github/java-tests/impact-map.json:make java_affected ARGS="--scope focused" # select focused checks; --scope full for merge readiness
make java_affected_run ARGS="--scope focused" # run once if no applicable evidence exists
make java_affected ARGS="--publish-results" # publish saved results without rerunning
Without
gh, drop--update-pr, pastetarget/java-tests/local-pr-results.mdbetween the markers,and post
target/java-tests/local-pr-results-details.mdas a PR comment.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
ContextFileFqnRepairMigrationITclass locally on PostgreSQL+OpenSearch and MySQL+Elasticsearch (6/6 tests pass on each). The new subfolder test reproduces the bug report's exact scenario (filexin folderYdamaged to bare namexwith an edit tag, plus a subfolderxunderYtaggedPII.NonSensitive+PersonalData.SpecialCategory): afterrepairAll, the subfolder still shows only its two original tags and the bare-nametag_usagerow count is unchanged, confirming the file's rows were not moved onto the subfolder's hash. The glossary-term test creates a glossary named like the folder and a term named like the file, asserting the term keeps only its own tags after repair.UI screen recording:
Not applicable — backend-only migration fix (no UI changes).
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.docs/decisions/(see itsREADME.md). This description is gone fromgit logafter the squash-merge.Automatic Fixes PRs can be configured here.
The Java guide requirements must be satisfied before merging; no new functional failure was established.
Findings
Summary
The PR checks both stored and derived FQNs across entity tables before moving
tag_usagerows.Reviews (3) · Last reviewed commit: "Address review: extract helpers, registe..." · Reviewed by Greptile