Skip to content

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

Merged
yan-3005 merged 7 commits into
mainfrom
fix/7854-workflow-tag-rule-negation
Oct 26, 2026
Merged

yan-3005 merged 7 commits into
mainfrom
fix/7854-workflow-tag-rule-negation

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

A customer reported two problems with tag rules in a workflow's Check Condition node. Both are in the shared JSON Logic rule editor (QueryBuilder). The backend rule engine evaluates whatever rule is stored correctly; the editor was storing or displaying the wrong one.

  1. "Is Not" / "Not In" / "Is Not Set" on a list field built the wrong rule. RAQB negates per element, so "Tags Is Not X" was saved as some(tags, tagFQN != X), which means "has a tag other than X". An untagged asset failed it, and an asset tagged X plus another tag passed it. "Is Not Set" saved some(tags, tagFQN == null), which never matches anything. The same applies to every list field (Owners, Reviewers, Domains, Data Products, Column Tags, table custom-property rows).
  2. A top-level NOT was hidden. A rule written through the API, such as {"!":{"and":[some(tags, tagFQN == X)]}}, loaded with the NOT intact and kept it on save, but the editor never drew it. The node read "Tags Is X", the opposite of what runs.

Fix

  • Save (utils/queryBuilder/formatters.ts): these rows are now stored as a negation of the whole list, !some(tags, tagFQN == X), !some(tags, in [...]) and !some(tags, tagFQN != null).
  • Load (utils/queryBuilder/tree.ts): those shapes, and a negated single-rule group like the customer's, are mapped back to the same row. The customer's API rule now reads "Tags Is Not X".
  • The save and load rewrites (utils/queryBuilder/jsonLogicNegation.ts) cover exactly the same shapes. Negations the loader can't turn back into a row, such as Related Terms "Not Contains", keep their previous form.
  • NOT the editor can't express as a row (for example NOT around two conditions): the group now shows a NOT badge, with helper text that holds under the negation ("At least one condition must not match" / "No condition can match"). This is in the new QueryBuilderConjunctionHint, used in the group header and for a negated root drawn as peer cards. The canvas still offers no NOT toggle.
  • Who this affects: every JSON Logic consumer of the editor: workflow check conditions and trigger filters, Collect Metadata, Data Asset Rules, and Data Contract semantics. Data Contract's existing toNegatedRule rewrite gives the same result applied on top (unit-tested).
  • The stored format is recorded in docs/decisions/2026-10-26-negated-list-conditions-are-stored-as-negated-some.md.

Rules saved before this change are migrated (2.0.7). A stored some(tags, tagFQN != X) loads as the same "Is Not" row as the corrected shape, so without a migration it would keep its old meaning until its next save and then change. The 2.0.7 data migration (migration/utils/v207/NegatedListRuleMigration.java) rewrites every stored rule once, using the same rewrite as the editor (NegatedListRuleRewriter, tested against the same case table). From the upgrade on, every rule runs as its row reads, and saving an untouched rule leaves it unchanged. It covers:

  • Workflows: Check Condition rules and the event trigger filter (a single string or one per entity type). These are stored through WorkflowDefinitionRepository.createOrUpdate, not SQL, so each changed workflow is redeployed to Flowable. A workflow that fails to redeploy is logged, with a hint to save or redeploy it, and the migration continues, like earlier workflow migrations. One broken workflow can't block the upgrade.
  • Data Contract semantics: keyset batches of 1,000. Only contracts whose JSON contains a some are parsed, and only rows that change are written. Inherited contracts aren't copied per table, so the work scales with contracts that were actually written.
  • Entity Rules settings (Data Asset Rules).

Each part is a runOnce step in the MySQL and Postgres v207 migrations. Nothing under an explicit ! is rewritten, by the editor or the migration. The editor offers no NOT, so such a rule came through the API and its per-element meaning was intended. For example, !some(tags, tagFQN != X) ("every tag is X") keeps its meaning.

Release note needed:

  • Every existing "Is Not" / "Not In" / "Is Not Set" rule on a list field (Tags, Owners, Domains, …) changes to the corrected meaning at upgrade.
  • A trigger filter is an exclusion, so 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.
  • Collate: Reverse Metadata channel filters use the same editor; they are migrated by the counterpart Collate PR open-metadata/openmetadata-collate#7873, which reuses MigrationUtil.rewriteNegatedListRule.

Before and after

The customer's API rule {"!":{"and":[Tags == PII.Sensitive]}}. Before, it reads "Tags Is Sensitive", the opposite of what runs:

Before: API rule reads as Is

After, it reads "Tags Is Not Sensitive":

After: API rule reads as Is Not

NOT around two conditions. Before, the NOT is invisible:

Before: multi-condition NOT hidden

After, the NOT badge and negated helper text are shown:

After: NOT badge shown

Choosing "Is Not" on Tags in the editor (the screen looks the same before and after; the saved rule is what changed):

Before: Is Not selected
After: Is Not selected

Saved rule
Before {"and":[{"some":[{"var":"tags"},{"!=":[{"var":"tagFQN"},"PII.Sensitive"]}]}]} (has a tag other than X)
After {"and":[{"!":{"some":[{"var":"tags"},{"==":[{"var":"tagFQN"},"PII.Sensitive"]}]}}]} (no tag is X)

Evaluated with the backend's json-logic-java 1.0.7 (the engine RuleEngine uses; LogicOps doesn't override some, !=, ! or in):

Rule no tags only X X + Y only Y
Old "Is Not" / "Not In" false false true true
New "Is Not" / "Not In" true false false true
Old "Is Not Set" false false false false
New "Is Not Set" true false false false

Type of change:

  • Bug fix

High-level design:

The rule editor keeps RAQB's internal tree unchanged. The only translation is at the JSON Logic save/load boundary:

  • Save: toEngineJsonLogic runs after QbUtils.jsonLogicFormat.
  • Load: fromEngineJsonLogic runs after migrateJsonLogic and before QbUtils.loadFromJsonLogic.

Both directions walk and/or/! and rewrite only these shapes:

RAQB shape Stored shape
some(v, != X) !some(v, == X)
some(v, !in) !some(v, in)
some(v, !contains) !some(v, contains)
some(v, == null) !some(v, != null)

On load, a single-rule !and[x] / !or[x] is unwrapped only when x becomes a row; any other NOT stays a negated group, so the canvas can show it. Elasticsearch output is untouched.

Alternatives I rejected:

  • Turning on RAQB showNot: the main canvas (QueryBuilderCanvas) replaces RAQB's <Builder> and never reads properties.not, so this alone shows nothing. It also offers a generic NOT toggle the product doesn't want.
  • Switching list fields to RAQB mode: 'array' with none: a much larger change to the field configs and the canvas.
  • Fixing it in the backend: the engine is correct for the rule it's given.

Tests:

Use cases covered

  • A tag rule written through the API with a top-level NOT opens as "Tags Is Not X" with no hidden negation.
  • A NOT around several conditions is drawn with a NOT badge and correct helper text, in both editable and read-only/view mode.
  • Choosing "Is Not" / "Not In" / "Is Not Set" on a list field saves a rule that means "no element matches", and reopens as the same row.
  • Related Terms "Not Contains" / "Not Equals" and the seeded "Is Set" rules (some(reviewers, fqn != null)) are untouched.
  • Data Contract semantics: the existing rewrite on top of the new output changes nothing.

Unit tests

  • Added src/utils/queryBuilder/jsonLogicNegation.test.ts: 20 tests. They cover the pure save/load rewrites, idempotency, the Data Contract rewrite on top, and round trips through the real builder config. 5 of them fail with the save/load hookup reverted.
  • Updated QueryBuilderCanvas.test.tsx: 3 new negation tests (badge on a negated group, badge on a negated root drawn as peer cards, no badge plus an "Is Not" row for the customer's shape). 2 fail with the canvas change reverted.
  • Jest run of the affected areas (src/utils/queryBuilder, src/components/common/QueryBuilder, src/components/WorkflowDefinitions, src/components/DataContract, src/components/DataAssetRules, src/utils/JSONLogicSearchClassBase): 73 suites, 1088 tests passed.

Backend integration tests

  • Added NegatedListRuleMigrationIT (openmetadata-integration-tests), 2 tests against the real database, rule engine and Flowable:
    • a contract with the old "Is Not" rule fails an untagged table; after the migration it passes and the stored rule is in the new shape;
    • a workflow's Check Condition rule is rewritten in storage and in the deployed Flowable process (rulesExpr).
  • Run alone: 2/2 on MySQL+ES and 2/2 on Postgres+OpenSearch.
  • Unit tests: NegatedListRuleRewriterTest (17: the same case table as the UI, idempotency, non-JSON input, and truth tables from json-logic-java) and NegatedListRuleMigrationTest (6: workflow rule discovery, per-entity filters, contract batching, entity rules).
  • make java_affected_run:

Local Java test run: PASSED

Step Scope Classes Tests Failed Skipped Result
unit openmetadata-service (11 classes) 11 139 0 0 passed
integration mysql-elasticsearch · parallel 23 1282 0 73 passed
integration mysql-elasticsearch · isolated 2 6 0 0 passed
integration postgres-opensearch · parallel 23 1282 0 73 passed
integration postgres-opensearch · isolated 2 6 0 0 passed

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Added playwright/e2e/Features/Workflows/WorkflowCheckConditionNegation.spec.ts, 3 tests. The spec is covered by the existing Features/Workflows/** impact-map entry.
    • an API rule !and[Tags Is X] opens as "Is Not" with no NOT badge;
    • a NOT around several conditions shows the NOT badge and negated helper text;
    • choosing "Is Not" in the editor saves !some(tags, tagFQN == X) in the workflow PUT.
  • All 3 fail with the UI fix reverted (checked against the same running stack).
  • Ran locally against an OSS server built from this branch (MySQL 8.4, Elasticsearch 9.3.0, Vite dev server, PLAYWRIGHT_IS_OSS=true). 60 passed (56 existing tests + the 3 new ones + setup/teardown):
    • Pages/DataContractsSemanticRules.spec.ts: all Owner / Domain / Data Product / Description / Version / DisplayName / Updated-on rules, including Is_Not, Not_In, Is_Not_Set and Not Contains;
    • Pages/DataContracts.spec.ts: the semantic tests, including "Semantic with Not_Contains Operator should work for Tier, Tag and Glossary";
    • Features/Workflows/ChangeRequestReviewLifecycle.spec.ts: all 7;
    • Features/Workflows/WorkflowCheckConditionNegation.spec.ts: 3/3.
  • After the final self-review fix, the new spec was re-run: 3/3 passed.
  • yarn lint:playwright: 0 errors, and none of the existing warnings are in the new spec.

Manual testing performed

  1. Built the server from this branch and ran migrations on MySQL 8.4 + Elasticsearch 9.3.0. Served the UI with the Vite dev server and logged in as admin.
  2. Created workflows through POST /api/v1/governance/workflowDefinitions with:
    • the customer's rule {"!":{"and":[some(tags, tagFQN == "PII.Sensitive")]}};
    • a NOT around two tag conditions;
    • a plain "Tags Is PII.Sensitive" rule.
  3. Opened each Check Condition node. The first reads "Tags | Is Not | Sensitive", and the second shows the NOT badge with "At least one condition must not match" (screenshots above).
  4. On the plain rule, entered edit mode, switched the operator to "Is Not", saved the node and the workflow, and checked that the PUT payload's rules is {"and":[{"!":{"some":[…"==":…]}}]}.
  5. Reverted the UI changes, repeated steps 3–4 for the "before" screenshots, and confirmed the old payload some(tags, tagFQN != X).

UI screen recording:

Not applicable: this is a bug fix, not a UI feature. Before/after screenshots from the run above are included instead.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation> (conventional-commit title; the issue is in the Collate tracker and is linked above).

  • My PR is linked to a GitHub issue via Fixes … above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable (no schema changes).

  • For a UI feature or feature task: not applicable (bug fix); screenshots above.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Reviewed with a fresh-context reviewer, then re-reviewed after the fix (no 🔴). Fixed: Related Terms "Not Contains" / "Not Equals" no longer save as a negation the loader can't turn back into a row (new test row). Answered: rules stored before this change keep their old meaning until re-saved. Now handled by the 2.0.7 migration (see above). After the review, the branch was squashed into 5a294eab92. The only changes since then are a test name and the decision record's wording.
  • Decision check: adds docs/decisions/2026-10-26-negated-list-conditions-are-stored-as-negated-some.md.

  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The PR still needs failed workflow deployments to remain retryable before merging.

Findings

  1. P1 Failed deployments lose automatic recovery ▶

Summary

Makes list-field exclusions mean “no element matches” and shows group negations in the editor.

  • List-field “Is Not” rules now mean that no item matches.
  • Negated groups now show a NOT badge and matching helper text.
  • The 2.0.7 upgrade rewrites saved list-field rules across the catalog.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Editor rows"] --> B["toEngineJsonLogic"]
  B --> C["Stored JSON Logic"]
  C --> D["fromEngineJsonLogic"]
  D --> A
  E["Legacy stored rules"] --> F["2.0.7 migration"]
  F --> C
  F --> G["Redeploy changed workflows"]
Loading

Reviews (6) · Last reviewed commit: "refactor(migrations): keep the 2.0.7 mig..." · Reviewed by Greptile

…rules

The JSON Logic rule editor (workflow check conditions and trigger filters,
data asset rules, data contract semantics) saved "Tags Is Not X" as
some(tags, tagFQN != X), which the rule engine reads as "has a tag other
than X": an untagged asset failed it and one tagged X plus another tag
passed it. "Not In" and "Is Not Set" on multi-value fields had the same
per-element problem. These now save as a negation of the whole list
(!some(tags, tagFQN == X)) and load back into the same row. Negations the
loader cannot turn back into a row (Related Terms "Not Contains") keep
their previous shape.

A NOT the editor cannot express as a row (one written through the API
around several conditions) was loaded but never drawn, so the node read
as the opposite of what runs. The group now shows a NOT badge and helper
text that holds under the negation.

Rules saved before this change keep their old meaning until re-saved.
The stored shape is recorded in
docs/decisions/2026-10-26-negated-list-conditions-are-stored-as-negated-some.md.
@yan-3005
yan-3005 requested a review from a team as a code owner October 26, 2026 09:07
@yan-3005
yan-3005 requested review from Rohit0301 and a balanced review from Copilot October 26, 2026 09: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.

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 insufficient remaining quota.

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

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 989 → 991
- 2 added, 0 removed, 14 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/common/QueryBuilder/QueryBuilderCanvas/QueryBuilderCanvas.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/QueryBuilder/QueryBuilderCanvas/QueryBuilderConjunctionHint.tsx

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/constant/config.ts
  openmetadata-ui/src/main/resources/ui/playwright/e2e/fixtures/pages.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/admin.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/advancedSearch.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/entity.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/waitHelpers.ts
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/CustomControls.tsx
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/NodeConfigSidebar.tsx
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/NodeFormSidebar.tsx
  … and 4 more

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

Copilot AI balanced review requested due to automatic review settings October 26, 2026 09:07

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 insufficient remaining quota.

@yan-3005 yan-3005 self-assigned this Oct 26, 2026
@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: 79%
79.67% (130609/163932) 66.22% (46051/69539) 69.11% (26106/37770)

Rules saved before the editor fix keep their per-element meaning
("has a tag other than X") while their row reads "Is Not X", and would
change meaning the next time someone saves them. The 2.0.7 data
migration rewrites them once, with the same rewrite the editor uses, so
every rule runs as its row reads from the upgrade on:

- workflow check conditions and event trigger filters, stored through
  the repository so each changed workflow is redeployed to Flowable
- data contract semantics, in keyset batches, parsing only contracts
  with a list condition
- the entity rules settings

Each part is a runOnce step; a failed workflow deploy fails the step so
the next run retries it.
@yan-3005
yan-3005 requested a review from a team as a code owner October 26, 2026 10:33
@yan-3005
yan-3005 requested review from manerow and a balanced review from Copilot October 26, 2026 10:33

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 insufficient remaining quota.

… map

A trigger filter stored as a string is a JSON-encoded map of entity type
to rule, the only string form the trigger reads. The migration handed the
whole string to the rewriter, which saw the map and changed nothing.
Decode it, rewrite each rule, and store it back as a string.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 10:40

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 insufficient remaining quota.

@yan-3005
yan-3005 enabled auto-merge October 26, 2026 11:23
@anuj-kumary

Copy link
Copy Markdown
Member

Regression review

I checked the fix against json-logic-js using this PR's own jsonLogicNegation.ts. It is correct for the reported case. !and[Tags Is X] now reopens as "Is Not X", and it saves as !some(tags, ==X) with the same behaviour as before. Re-saving a rule that is already in the new shape leaves it unchanged. The seeded "Is Set" rules, Data Contract's toNegatedRule, RuleEnforcementUtils and the JSON Logic → Elasticsearch conversion are not affected.

I found these regressions:

1. A rule written through the API under an explicit ! changes meaning, at upgrade and on a save that changes nothing.
toEngineJsonLogic and NegatedListRuleRewriter both go inside an explicit ! and rewrite the condition there. The 2.0 editor can't produce a !, so any rule with one was written through the API, and its per-element meaning was intended.

Stored rule (API) Meaning today After the migration or a re-save
!some(tags, tagFQN != X) every tag is X (no tags → true, X+Y → false) !!some(tags, == X): has X (no tags → false, X+Y → true)
!some(tags, !in [X]) every tag is in [X] has X
!some(tags, tagFQN == null) always true has at least one tag

Suggestion: don't rewrite inside an explicit ! in either direction. If that's not possible, add these shapes to the shared case table and call them out in the release note.

2. One workflow that fails to deploy blocks the upgrade.
rewriteWorkflowRules throws when any workflow fails to redeploy. That fails migrate, and the server won't start. The earlier workflow migrations (v1105, v1122, v1133, …) log the error and continue. A workflow that can't be deployed for an unrelated reason now stops the whole upgrade. Consider logging the failure and continuing, or at least skipping workflows whose rules this migration doesn't change.

3. Collate: Reverse Metadata filters are not migrated.
In Collate 2.0.x, each Reverse Metadata channel has a filter built with this same editor (format: queryBuilder, outputType: jsonlogic, entity type table). It is evaluated by json-logic-java. This migration doesn't cover it. Once Collate takes this change, an existing "Tags Is Not X" channel filter keeps its old per-element meaning, looks the same as a new-shape rule, and changes meaning the next time someone saves the channel. Collate's v210 ReverseMetadataAgentMigration also copies these filters into the agent configs unchanged. This needs a follow-up migration on the Collate side, not a change here.

Behaviour change that needs a release note (intended):

  • Every existing "Is Not" / "Not In" / "Is Not Set" rule on a list field changes meaning at upgrade.
  • A matching trigger filter excludes the entity. So a trigger filter with "Tags Is Not X" now also excludes untagged entities.
  • Workflows whose branches were inverted to work around the old bug need them swapped back.

Minor: contracts are rewritten through contractDAO.update, which skips the search index and version history. The last contract result stays based on the old rule until the next validation run.

The editor offers no NOT, so a rule with one came through the API and a
per-element condition under it was meant per element. Neither the
editor's save/load rewrite nor the 2.0.7 migration reaches inside an
explicit `!` any more, so `!some(tags, tagFQN != X)` ("every tag is X")
keeps its meaning at upgrade and on a save that changes nothing.

The migration now logs a workflow it cannot redeploy and continues, as
earlier workflow migrations do, instead of failing the upgrade.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 11:51
@yan-3005

Copy link
Copy Markdown
Contributor Author

@anuj-kumary thanks. I checked each point before changing anything.

1. API rules under an explicit ! (correct, fixed in a55914b). I reproduced it: !some(tags, tagFQN != X) came back as !!some(tags, == X). Neither the editor's save/load rewrite nor the 2.0.7 migration reaches inside an explicit ! any more, so all three of your shapes keep their meaning, at upgrade and on a save that changes nothing. The customer's !and[Tags Is X] still opens as "Is Not X", because !some(== X) means the same thing either way.

  • Your shapes plus !and[some(!= X)] are in the shared case table: NegatedListRuleRewriterTest and jsonLogicNegation.test.ts.
  • The TS side also checks a full load → save through the real builder config, and the saved rule has the same meaning as the stored one.
  • Also recorded in the decision record.

2. One undeployable workflow blocking the upgrade (correct, fixed). rewriteWorkflowRules now logs the failure, saying to save or redeploy that workflow, and continues, like v1105/v1133. Workflows whose rules don't change are no longer deployed at all.

3. Collate Reverse Metadata filters (correct). I confirmed the channel filter is format: queryBuilder, outputType: jsonlogic, so it's the same editor and the same stored shape. This needs a Collate-side follow-up migration, plus the v210 agent config copy. I'll raise it there. For OSS, the only jsonlogic editor fields in 2.0 are checkEntityAttributesTask.rules and semanticsRule (contracts and entity rules), plus the event trigger filter. All of them are covered.

Minor (contract DAO update): agreed it skips search and version history. That's deliberate for a format-only rewrite and follows the existing v210 DataContractEntityReferenceMigration. The result refreshes on the next validation.

Release note: I'll add the trigger-filter point to the description. A trigger filter "Tags Is Not X" is an exclusion, so after the upgrade it also excludes untagged entities.

Tests on a55914b: Jest 73 suites / 1100 passed; Java unit NegatedListRule* 27 passed; NegatedListRuleMigrationIT 2/2 on MySQL+ES and Postgres+OS.

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 insufficient remaining quota.

Comment on lines +92 to +98
} catch (RuntimeException e) {
// Flowable reports a failed deploy with its own unchecked exceptions.
LOG.error(
"[v207] Failed to rewrite workflow '{}'; save it again to apply the corrected rules",
stored.getName(),
e);
}

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 Failed deployments lose automatic recovery

When a workflow deployment fails, this catch logs the error and lets runOnce mark the migration step complete. Rerunning the upgrade then skips the failed workflow. The repository stores corrected rules before deploying them, so the editor can show the new rule while Flowable still runs the old one.

Removing the fallback redeployment also prevents recovery after an interruption between storage and deployment. Keep failed deployments retryable, including workflows whose stored rules were already rewritten.

Collate stores reverse metadata filters built with the same editor; its
2.0.7 migration rewrites them with this same rewrite.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 12:00

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 insufficient remaining quota.

One class for the version's migration: the negated list rule rewrite and
its workflow, data contract and entity rules steps move into
v207/MigrationUtil, with rewriteNegatedListRule public for Collate.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 12:13

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 insufficient remaining quota.

@gitar-bot

gitar-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 closed / 3 findings

🔴 High risk · The 2.0.7 migration rewrites stored workflow, trigger, contract, and entity rules, which could reverse automation branches or validation outcomes across existing assets.

Makes tag and list-field "Is Not" / "Not In" / "Is Not Set" rules mean "no element matches" and shows top-level NOT groups in the rule editor, with a 2.0.7 migration rewriting stored rules. Resolved this session: legacy string-encoded trigger filters are now rewritten, and rows inside a NOT group keep their intended per-element meaning. No open findings; approved.

✅ 3 closed
✅ Bug: Legacy string trigger filters (a JSON-encoded map) are never rewritten

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v207/NegatedListRuleMigration.java:148-155 📄 openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v207/NegatedListRuleMigrationTest.java:62-69
When trigger.config.filter is textual, addFilterFields hands the whole string to NegatedListRuleRewriter.rewrite. The runtime doesn't read that string as a rule. TriggerEntityFilter.fromFilterString parses it as a per-entity map such as {"table":"<rule>"} and rejects plain rule strings, and the UI's toFilterMap (WorkflowSerializationUtils.ts) reads it the same way. The rewriter sees an object whose single key is table, not some/!/and, so it leaves the rule inside unchanged. Those older workflows keep the per-element some(tags, != X) filter while the editor now shows it as "Is Not X", which is the mismatch this migration is meant to remove. checkConditionRulesAndTriggerFilterAreRewritten covers this up because it uses a raw rule as the string filter, a shape the runtime rejects. Fix: when the textual filter parses to an object, rewrite each value and serialize the map back into the string. Then update the test to use the real legacy shape.

✅ Bug: Rows inside a NOT group keep the per-element meaning they were meant to lose

📄 openmetadata-ui/src/main/resources/ui/src/utils/queryBuilder/jsonLogicNegation.ts:124-128 📄 openmetadata-ui/src/main/resources/ui/src/utils/queryBuilder/jsonLogicNegation.ts:148-152 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v207/NegatedListRuleRewriter.java:57-69 📄 docs/decisions/2026-10-26-negated-list-conditions-are-stored-as-negated-some.md:29-31
After this commit, neither toEngineJsonLogic nor fromEngineJsonLogic looks inside a ! unless it wraps a single reversible row. The trouble is that the editor can still show and edit NOT groups. A negated multi-condition group gets a NOT badge in edit mode, and so does a negated root drawn as peer cards. If a user adds or switches a Tags row to "Is Not X" inside one of those groups, toEngineJsonLogic leaves RAQB's raw some(tags, tagFQN != X) in place, the same per-element shape this PR set out to remove. The reverse happens on load. A stored !and[A, !some(tags, == X)] keeps its inner !some unconverted, so RAQB shows a row that doesn't match the stored rule.

Take !and[A, some(tags, != X)] on an untagged asset. The canvas shows "NOT (A and Tags Is Not X)". Read with the ADR's meaning of "Is Not", the Tags row matches. Per element, some(...) is false. So the whole rule evaluates differently from what the canvas shows, and the PR's promise that "every rule runs as its row reads" doesn't hold inside negated groups. The migration also skips these subtrees, so legacy rows inside API-authored NOT groups keep the old meaning.

The new 'a NOT around a per-element row' case (!and[tagIsNot(A)]) shows the problem. It loads as a NOT group around an "Is Not A" row and stores "every tag is A", which most readers would take to mean "has tag A". There are two ways to fix this. One is to keep rewriting rows inside ! groups that render as rows, both on save and on load. Leave a bare !some(...) untouched only when it can't be drawn as a row. The other is to make NOT groups read-only in the canvas so no per-element row can be authored under them, and say so in the ADR.

Closed: Bug: Collect Metadata conditions and lifecycle gate conditions not migrated

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v207/NegatedListRuleMigration.java:133-145
workflowRules only collects checkEntityAttributesTask config.rules and the event trigger filter. A collectMetadataTask node also stores a JSON Logic config.conditions. MetadataCollectionService.outstanding evaluates it with RuleEngine, and CollectMetadataForm renders it through QueryBuilderSection. The PR description lists Collect Metadata as an affected consumer. After upgrade, a stored some(tags, tagFQN != X) condition reads "Is Not X" but keeps running per element. The form is forceReadOnly, so a re-save will never fix it. The matching lifecycle.gates[].conditions must also stay equal to the compiled node, so it needs the same rewrite. Add both locations to workflowRules.

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 added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 063bba1 Oct 26, 2026
87 of 91 checks passed
@yan-3005
yan-3005 deleted the fix/7854-workflow-tag-rule-negation branch October 26, 2026 16:11
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.

4 participants