Skip to content

fix(governance): validate workflow edge conditions and node references (1.13) - #32371

Merged
yan-3005 merged 2 commits into
1.13from
backport/governance-workflow-edge-condition-validation-1.13
Sep 3, 2026
Merged

yan-3005 merged 2 commits into
1.13from
backport/governance-workflow-edge-condition-validation-1.13

Conversation

@yan-3005

@yan-3005 yan-3005 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Backport of #32326 to 1.13.

Describe your changes

Governance workflow edge condition values and node references are interpolated into the Flowable sequence-flow expressions that drive conditional transitions (${from_result == 'condition'}). This PR restricts those values so only well-formed input is accepted.

  • Add WorkflowExpressionValidator with the allowed patterns (a condition must be empty — unconditional — or contain at least one alphanumeric plus space . _ -; a conditional edge's source must be an identifier).
  • Validate the condition and source node of conditional edges at the create/update boundary in WorkflowDefinitionRepository (rejected with a clear 400). Unconditional edges are untouched, so node names keep the broader entityName contract.
  • Guard expression construction in Edge as a defense-in-depth check.
  • In edge.json: pattern/maxLength on condition (aligned with the server-side validator) and minLength/maxLength on from/to.

No change to the generated BPMN for valid workflows (the expression string is identical), so no redeploy/migration is required.

Type of change

  • Bug fix

Tests

  • Unit: WorkflowExpressionValidatorTest, EdgeTest, WorkflowDefinitionRepositoryEdgeSafetyTest.

Checklist

  • I have read the CONTRIBUTING document.
  • My PR includes tests for the changes made.

Restrict the values interpolated into conditional-edge Flowable JUEL
expressions (${from_result == 'condition'}) to a well-formed character set.

- Add WorkflowExpressionValidator with the allowed patterns.
- Validate the condition and source node of conditional edges at the
  create/update boundary in WorkflowDefinitionRepository; unconditional
  edges keep the broader entityName contract.
- Guard expression construction in Edge as a defense-in-depth check.
- Add pattern/maxLength on edge condition and length bounds on from/to.
- Add unit tests for the validator, Edge, and repository validation.
@yan-3005
yan-3005 requested a review from a team as a code owner September 1, 2026 13:25
@github-actions

github-actions Bot commented Sep 1, 2026

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 Sep 1, 2026
mohityadav766 added a commit that referenced this pull request Sep 2, 2026
…ss-test delete race

Fixes the last family of failures on the mysql lanes, and most of what is left
on postgres-opensearch. Symptom is one of:

  Api <entityService> instance for <uuid> not found
  Cannot invoke "EntityReference.getFullyQualifiedName()" because
      the return value of "Dashboard.getService()" is null

Single root cause: service-backed entity ITs create a fresh service per entity,
so an unqualified listEntities returns rows belonging to sibling tests. When a
sibling's @AfterEach hard-deletes its service mid-list, server-side hydration of
that row's service ref either throws or yields null.

BaseEntityIT gains a getEntityServiceFqn hook (default null, so non-service
entities are unaffected) and pins every unqualified list call to the entity's own
service. Service-backed subclasses override it. Also bumps the hard-delete
visibility wait from 15s to 45s for the change-event pipeline on the
pg-es-redis parallel lane, and waits for accepted async bulk entities before
asserting on them.

Taken from PR #32340 byte for byte, except for two classes it does not cover:

- PipelineResourceIT: same 7-line override; it hits the identical error and is
  the class that failed on the postgres-opensearch lane.
- DashboardResourceIT: same override, plus test_listDashboardsByService listed
  unscoped with limit=100 and then dereferenced getService() on every returned
  row. It builds its own ListParams, so the base-class hook cannot reach it —
  scoped the call to the service the test created, which is what a test of that
  name was already meant to do. Swept the module for the same shape; this was
  the only other instance (DatabaseSchemaResourceIT already scopes via
  setDatabase).

AuditLogResourceIT and RecognizerFeedbackRepositoryTest are pre-existing
failures on 1.13 unrelated to this branch (both also fail on #32373, the latter
also on #32371); their #32340 fixes are included since they are test-only.

Verified: test-compile and spotless clean across the module.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
mohityadav766 added a commit that referenced this pull request Sep 2, 2026
The openmetadata-service unit lane is red on every 1.13 PR, not just this one:
8 failures on #32400, #32371 and #32373. This branch already showed 6 — a strict
subset, the other 2 (AuthenticationCodeFlowHandlerTest) having been fixed by
#32408 landing on the base. Nothing here was caused by this branch; these are
the remaining 6.

Three assert against entities and fields that only exist on main/2.0, having been
backported wholesale:

- IndexMappingNestedFieldConsistencyTest asserted mappings for auditReport,
  aiApplication, llmModel and aiGovernance. None of those entities exist on 1.13.
- SearchIndexFactoryTest asserted page reindex fields include "parent"; page
  hierarchy is main-only.
- SearchRepositoryBehaviorTest expected the column child index to be aliased
  cluster_column_search_index; on 1.13 it is cluster_tableColumn.

EntityCsvTest covers domain/data-product validation on bulk edit.

SearchRepositoryBehaviorTest also gains a test for an EXTERNAL_HANDLER-only
change emitting no child-update call, which needs the accompanying
SearchRepository fix: appendUpdate/appendDelete/appendCreate appended a
separator unconditionally, so a propagation whose switch branch deliberately
emits nothing (certification, driven by propagateCertificationTags) produced a
whitespace-only script that still fired updateChildren against every child
index. The three guards only append the separator when the branch actually
wrote something.

That makes two product changes on this branch: the TestCaseRepository
null/EntityNotFound guard and these three separator guards. Everything else is
test-only.

Verified locally: EntityCsvTest 63, SearchIndexFactoryTest 200,
SearchRepositoryBehaviorTest 115, IndexMappingNestedFieldConsistencyTest 4 —
382 tests, 0 failures, 0 errors. Spotless clean.

Taken from PR #32340 byte for byte.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gitar-bot

gitar-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Backport adds validation for governance workflow edge conditions and node references to prevent injection into Flowable expressions, with server-side patterns, repository-boundary checks, and JSON schema constraints. Stricter condition/node rules may reject existing workflows on update if they contain now-disallowed characters (e.g. &, (, ,) or non-identifier source nodes, even for unrelated edits—consider documenting this in release notes and logging warnings for pre-existing custom workflows rather than hard-failing.

✅ 1 resolved
✅ Edge Case: Stricter condition/node rules may reject existing workflows on update

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDefinitionRepository.java:196-210 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowExpressionValidator.java:15-20
Because validateWorkflow runs in prepare for both create and update, any previously-stored custom workflow whose conditional-edge condition contains now-disallowed characters (e.g. &, (, ,) or whose source node name is not a pure [A-Za-z0-9_] identifier will be rejected with a 400 on the next PUT, even when the edit is unrelated. This is largely the intended security hardening (such values would produce malformed/injectable JUEL), and seed workflows are unaffected, but on a 1.13 backport it can surprise users with custom governance workflows. Consider documenting this in release notes and, if needed, logging a warning for pre-existing definitions rather than hard-failing unrelated updates.

Options

Display: compact → Showing less information.

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

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@yan-3005
yan-3005 merged commit 295487c into 1.13 Sep 3, 2026
126 of 129 checks passed
@yan-3005
yan-3005 deleted the backport/governance-workflow-edge-condition-validation-1.13 branch September 3, 2026 09:48
@yan-3005 yan-3005 self-assigned this Nov 19, 2026

This branch was previously deployed

1 inactive deployment
test — d46cd21d Deployed Sep 2, 2026 by yan-3005 via playwright-ci-postgresql (4, 6) #78239
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