Skip to content

fix(workflows): make tag "Is Not" mean "not tagged" and show negated rules (2.0) - #36263

Merged
yan-3005 merged 2 commits into
2.0from
fix/7854-workflow-tag-rule-negation-2.0
Oct 27, 2026
Merged

yan-3005 merged 2 commits into
2.0from
fix/7854-workflow-tag-rule-negation-2.0

Conversation

@yan-3005

@yan-3005 yan-3005 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes open-metadata/openmetadata-collate#7854

Update (2026-10-27): 2.0.7 is frozen, so this migration now runs in 2.0.8 (v208 / 2.0.8-collate); the code is unchanged. The main-branch counterpart is #36321. Unit tests re-run after the move pass. The verification results below were recorded while the migration ran as 2.0.7 (version names in them now read 2.0.8); the integration and end-to-end migrate runs under 2.0.8 are pending (Docker was unavailable) and will be posted here.

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:

  1. "Is Not" / "Not In" / "Is Not Set" on a list field saved the wrong rule. 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.
  2. A NOT written through the API was hidden. The 2.0 builder runs with 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 old QueryBuilderWidget / QueryBuilderWidgetV1, not the shared QueryBuilder + QueryBuilderCanvas. So:

  • Rewrite helpers: the same utils/queryBuilder/jsonLogicNegation.ts as on main (identical file), plus a small hasExplicitNegation.
  • QueryBuilderWidget (workflow Check Condition, Data Asset Rules): saves through toEngineJsonLogic and loads through fromEngineJsonLogic. The customer's !and[Tags Is X] opens as "Tags Is Not X".
  • QueryBuilderWidgetV1 (Data Contract semantics): saves through toEngineJsonLogic. It loads from the stored RAQB tree, so no load-side change is needed.
  • Hidden NOT: instead of the canvas badge used on 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.
  • 2.0.8 migration: the backend is identical to fix(workflows): make tag "Is Not" mean "not tagged" and show negated rules #36220. v208/MigrationUtil rewrites 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. rewriteNegatedListRule is 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:

  • Bug fix

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.
    • A NOT around several conditions shows the NOT control.
    • The customer's !and[Tags Is X] shows no NOT and reads "Is Not".
    • Both fail against the unfixed 2.0 widget.
  • Jest on the affected areas (utils/queryBuilder, QueryBuilderWidget, QueryBuilderWidgetV1, DataContract, WorkflowDefinitions, DataAssetRules, JSONLogicSearchClassBase): 36 suites, 664 passed.
  • Java v208/MigrationUtilTest: 27 passed on 2.0.

Backend integration tests

  • NegatedListRuleMigrationIT on 2.0: 2/2 on MySQL+ES, 2/2 on Postgres+OS.
    • A data contract with the old rule fails an untagged table; after the migration it passes.
    • A workflow's rule is rewritten in storage and in the deployed Flowable process.
  • The migration code is identical to fix(workflows): make tag "Is Not" mean "not tagged" and show negated rules #36220. There it was also verified end to end with the real migrate on 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

Manual testing performed

Covered by the end-to-end migration runs on #36220, which use the same backend code.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR is linked to a GitHub issue via Fixes … above.
  • I have added tests (unit / integration as applicable) and listed them above.
  • Self-review: the backend is identical to fix(workflows): make tag "Is Not" mean "not tagged" and show negated rules #36220, which was reviewed (Gitar approved, Greptile and Anuj's review addressed). The 2.0-only UI wiring is covered by tests that fail without it.
  • Decision check: carries docs/decisions/2026-10-26-negated-list-conditions-are-stored-as-negated-some.md, which the migration cites.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The PR is not ready to merge because empty entity rules settings can still stop the upgrade.

Findings

  1. P1 Empty settings stop the upgrade ▶
  2. P2 String checks bypass named constants ▶
  3. P2 First-element access breaks the guide ▶
  4. P2 Unchanged values lack final ▶

Summary

Corrects how the editor saves negated list conditions and shows explicit NOT groups.

  • List-field “Is Not” rules now match the whole list.
  • The 2.0.8 upgrade rewrites saved list-negation rules across rule settings.

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]
Loading

Reviews (2) · Last reviewed commit: "fix(migrations): run the negated list ru..." · Reviewed by Greptile

…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.
@yan-3005
yan-3005 requested review from a team as code owners October 26, 2026 14:06
@yan-3005
yan-3005 requested review from pmbrull and shrabantipaul-collate and removed request for a team October 26, 2026 14:07
@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.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 26, 2026

static boolean rewriteEntityRules(final EntityRulesSettings rules) {
boolean changed = false;
for (final SemanticsRule semantic : rules.getEntitySemantics()) {

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.

P1 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;

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.

P2 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());

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.

P2 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!

Comment on lines +250 to +254
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);

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.

P2 Unchanged values lack final

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!

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 68%
68.37% (83106/121543) 53.3% (51544/96691) 54.02% (15322/28359)

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.
@gitar-bot

gitar-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown
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.

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

@sonarqubecloud

Copy link
Copy Markdown

@yan-3005
yan-3005 merged commit 1e46012 into 2.0 Oct 27, 2026
67 of 77 checks passed
@yan-3005
yan-3005 deleted the fix/7854-workflow-tag-rule-negation-2.0 branch October 27, 2026 16:25
@yan-3005 yan-3005 self-assigned this Nov 19, 2026

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 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.

2 participants