Repository navigation
fix(workflows): make tag "Is Not" mean "not tagged" and show negated rules (2.0) - #36263
Conversation
…rules (2.0) Backport of the main fix to the 2.0 rule editor and migration. The JSON Logic rule editor saved "Tags Is Not X" as some(tags, tagFQN != X), which the rule engine reads as "has a tag other than X". "Not In" and "Is Not Set" on list fields had the same flaw. The 2.0 QueryBuilderWidget and QueryBuilderWidgetV1 now save these as a negation of the whole list (!some(tags, tagFQN == X)) and load them back into the same row; rules under an explicit NOT are left as written. A NOT written through the API around several conditions was loaded but hidden (showNot is off). The 2.0 builder now shows its NOT control for a rule that already holds one. The 2.0.7 data migration rewrites rules stored in the old shape: workflow check conditions and event trigger filters (stored through the repository so each changed workflow is redeployed), data contract semantics and the entity rules settings. A workflow that fails to redeploy is logged and the upgrade continues.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
|
|
||
| static boolean rewriteEntityRules(final EntityRulesSettings rules) { | ||
| boolean changed = false; | ||
| for (final SemanticsRule semantic : rules.getEntitySemantics()) { |
There was a problem hiding this comment.
Empty settings stop the upgrade
If an installation has entityRulesSettings saved as {"entitySemantics": null}, this new loop throws NullPointerException. The settings write path accepts that value, and RuleEngine already treats it as no rules. Both database migrations call this method, so the error stops the upgrade to 2.0.7. Treat a missing list as empty and add a regression test.
| /** Only a contract with a list condition is parsed, so a catalog of plain contracts stays cheap. */ | ||
| public static int rewriteAndStore(final EntityDAO<?> contractDAO, final String json) { | ||
| final ObjectNode contract = | ||
| json.contains("some") ? (ObjectNode) JsonUtils.readTree(json) : null; |
There was a problem hiding this comment.
String checks bypass named constants
json.contains("some") uses a raw string where the repository guide requires a named constant. Use the existing SOME constant here. The same directive applies to "rulesExpr".equals(...) in NegatedListRuleMigrationIT.java. These repository requirements 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!
| .withRule("{\"<=\":[{\"length\":{\"var\":\"domains\"}},1]}"))); | ||
|
|
||
| assertTrue(MigrationUtil.rewriteEntityRules(rules)); | ||
| assertEquals(IS_NOT, rules.getEntitySemantics().get(0).getRule()); |
There was a problem hiding this comment.
First-element access breaks the guide
The new tests use get(0) on lists, but the repository guide requires Java 21's getFirst(). Replace this call and the other first-element assertions in this test. 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!
| UUID legacyId = UUID.randomUUID(); | ||
| String legacy = contract(legacyId, "legacy", LEGACY_IS_NOT); | ||
| String current = contract(UUID.randomUUID(), "current", IS); | ||
| String plain = "{\"id\":\"%s\",\"name\":\"plain\"}".formatted(UUID.randomUUID()); | ||
| EntityDAO<?> contractDAO = mock(EntityDAO.class); |
There was a problem hiding this comment.
The new Java tests leave unchanged locals and parameters non-final. The repository guide requires final where values are not reassigned. Apply it to these declarations and the same pattern elsewhere in the new tests, including NegatedListRuleMigrationIT.java. 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!
2.0.7 is already frozen, so the migration that rewrites stored negated list rules moves from 2.0.7 to 2.0.8. Only that migration moves: the 2.0.7 migration keeps exactly the steps it had before. No change in behaviour.
Code Review ✅ Approved🔴 High risk · The 2.0.8 migration rewrites stored list-rule logic across workflows and contracts, which could change asset matching and trigger unintended workflow branches. Corrects how list-field "Is Not", "Not In", and "Is Not Set" rules are saved and loaded in the 2.0 workflow and data contract builders, and adds a 2.0.7 migration that rewrites stored negated list rules. No open issues remain. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Describe your changes:
Fixes open-metadata/openmetadata-collate#7854
Backport of #36220 to
2.0, for the customer on 2.0.6.The same two bugs as on
main, in the 2.0 editor:some(tags, tagFQN != X)means "has a tag other than X": an untagged asset fails it, and an asset tagged X plus another tag passes it.showNot: false, so{"!":{"and":[...]}}loaded with its NOT intact but showed as the opposite.What's different from
main: 2.0 still renders the library's (RAQB's) stock antd<Builder>through the oldQueryBuilderWidget/QueryBuilderWidgetV1, not the sharedQueryBuilder+QueryBuilderCanvas. So:utils/queryBuilder/jsonLogicNegation.tsas onmain(identical file), plus a smallhasExplicitNegation.QueryBuilderWidget(workflow Check Condition, Data Asset Rules): saves throughtoEngineJsonLogicand loads throughfromEngineJsonLogic. The customer's!and[Tags Is X]opens as "Tags Is Not X".QueryBuilderWidgetV1(Data Contract semantics): saves throughtoEngineJsonLogic. It loads from the stored RAQB tree, so no load-side change is needed.main, the 2.0 builder turns on its own NOT control only for a rule that still holds a NOT after loading. A rule without one looks exactly as before. Rules under an explicit!are never rewritten, on save or by the migration.v208/MigrationUtilrewrites stored rules once: workflow check conditions and event trigger filters (stored through the repository, so each changed workflow is redeployed; a failed redeploy is logged and the upgrade continues), data contract semantics, and the entity rules settings.rewriteNegatedListRuleis public for the Collate 2.0 counterpart.Release note: existing "Is Not" / "Not In" / "Is Not Set" rules on list fields change to the corrected meaning at upgrade. A "Tags Is Not X" trigger filter now also excludes untagged entities. Workflows whose branches were inverted to work around this bug need the branches swapped back.
Counterpart: open-metadata/openmetadata-collate#7874 (Collate 2.0 backport) rewrites Reverse Metadata filters the same way and depends on this PR.
Type of change:
Tests:
Unit tests
utils/queryBuilder/jsonLogicNegation.test.ts(new on 2.0): 33 passed. It covers the shared case table, the explicit-NOT cases, and round trips through the real 2.0 antd config (jsonLogicSearchClassBase.getQbConfigs).QueryBuilderWidget.test.tsx: 2 new tests rendering the real 2.0 widget with the real JSON Logic config.!and[Tags Is X]shows no NOT and reads "Is Not".utils/queryBuilder,QueryBuilderWidget,QueryBuilderWidgetV1,DataContract,WorkflowDefinitions,DataAssetRules,JSONLogicSearchClassBase): 36 suites, 664 passed.v208/MigrationUtilTest: 27 passed on 2.0.Backend integration tests
NegatedListRuleMigrationITon 2.0: 2/2 on MySQL+ES, 2/2 on Postgres+OS.migrateon MySQL and Postgres: old rules rewritten, API!rules untouched, string trigger filter rewritten, workflow redeployed, and a re-run skips all steps.Playwright (UI) tests
WorkflowCheckConditionNegation.spec.tsonmaintargets the new canvas (query-builder-negated-group, the core-components operator select), which 2.0 doesn't have. The 2.0 widget behaviour is covered by the widget tests above. Before/after screenshots of themainUI are on fix(workflows): make tag "Is Not" mean "not tagged" and show negated rules #36220.Manual testing performed
Covered by the end-to-end migration runs on #36220, which use the same backend code.
Checklist:
Fixes …above.docs/decisions/2026-10-26-negated-list-conditions-are-stored-as-negated-some.md, which the migration cites.🤖 Generated with Claude Code
The PR is not ready to merge because empty entity rules settings can still stop the upgrade.
Findings
Summary
Corrects how the editor saves negated list conditions and shows explicit NOT groups.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Editor[Editor list condition] --> Rewrite[Negate the whole list] Stored[Existing stored rules] --> Migration[2.0.8 migration] Migration --> Rewrite Rewrite --> Saved[Corrected stored rules] Saved --> Deploy[Redeploy changed workflows]Reviews (2) · Last reviewed commit: "fix(migrations): run the negated list ru..." · Reviewed by Greptile