Repository navigation
fix(governance): validate workflow edge conditions and node references - #32326
Conversation
Governance workflow edge `condition` values and node names are used to build Flowable sequence-flow expressions. Restrict them to a safe character set so only well-formed values are accepted. - Add WorkflowExpressionValidator with the allowed patterns - Validate edge conditions and node names in WorkflowDefinitionRepository - Guard expression construction in Edge - Add a schema pattern on edge from/to/condition Covered by unit tests for the validator and Edge.
❌ 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 |
There was a problem hiding this comment.
Pull request overview
This PR hardens governance workflow definitions by validating edge condition values and node references used to construct Flowable JUEL expressions, reducing the risk of expression injection while keeping existing seed workflow values working.
Changes:
- Introduces
WorkflowExpressionValidatorwith safe patterns for edge conditions and node references. - Enforces condition and node-name validation at the workflow create/update boundary (
WorkflowDefinitionRepository) and at expression-construction time (Edge) for defense in depth. - Adds JSON Schema
patternconstraints for edgefrom/to/conditionand adds focused unit tests for the new validation behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-spec/src/main/resources/json/schema/governance/workflows/elements/edge.json | Adds schema-level regex validation for edge endpoints and condition values. |
| openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowExpressionValidator.java | Centralizes allowlisted patterns for JUEL-interpolated fields. |
| openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/Edge.java | Guards JUEL expression construction against unsafe from/condition values. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDefinitionRepository.java | Rejects unsafe node IDs and edge conditions at the persistence boundary with 400s. |
| openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/WorkflowExpressionValidatorTest.java | Adds unit coverage for safe/unsafe condition and node reference patterns. |
| openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/elements/EdgeTest.java | Verifies expression output and that unsafe inputs fail fast during edge construction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // the value is inert data. Allow the punctuation legitimate conditions use (e.g. "Tier.Gold") but | ||
| // exclude every character that could terminate the literal or introduce expression syntax | ||
| // (' " \ $ { } ( ) = etc.). | ||
| private static final Pattern SAFE_EDGE_CONDITION = Pattern.compile("^[A-Za-z0-9 ._-]+$"); |
| if (condition != null && !WorkflowExpressionValidator.isSafeCondition(condition)) { | ||
| throw BadRequestException.of( | ||
| String.format( | ||
| "Workflow '%s' has an edge with an unsafe condition: '%s'", | ||
| workflowName, condition)); | ||
| } |
| "condition": { | ||
| "description": "Defines if the edge will follow a path depending on the source node result.", | ||
| "type": "string" | ||
| "type": "string", | ||
| "pattern": "^[A-Za-z0-9 ._-]+$" | ||
| } |
| // Node names become JUEL variable-name prefixes on conditional edges; reject any that could | ||
| // break out of the generated expression (GHSA-cq2r-82mr-xv2h). | ||
| if (!WorkflowExpressionValidator.isSafeNodeReference(nodeId)) { | ||
| throw BadRequestException.of( | ||
| String.format( |
✅ Playwright Results — workflow succeededValidated commit ✅ 790 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 49m 40s ⏱️ Max setup 4m 32s · max shard execution 15m 23s · max shard-job elapsed before upload 18m 27s · reporting 7s 🌐 207.00 requests/attempt · 2.50 app boots/UI scenario · 25.46% common-shard skew Optimization targets still in progress:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
… edges Address review feedback: - Only validate the condition and source node of edges that carry a condition; unconditional edges keep the broader entityName contract, so existing workflows with descriptive node names are not rejected on update. - Treat an empty condition the same as null (unconditional) instead of rejecting it; allow empty in the edge.json condition pattern and bound its length. - Improve the 400 messages to name the edge and the allowed characters. - Add repository-level unit tests for edge validation.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (1)
openmetadata-spec/src/main/resources/json/schema/governance/workflows/elements/edge.json:21
- The PR description mentions adding a pattern on edge
from/toas well, but the schema still leaves those fields as unconstrainedstring. To keep the schema consistent with the rest of the spec (and with node naming viaentityName), consider referencingbasic.json#/definitions/entityNameforfromandto(which also applies maxLength/pattern).
"condition": {
"description": "Defines if the edge will follow a path depending on the source node result.",
"type": "string",
"maxLength": 256,
"pattern": "^[A-Za-z0-9 ._-]*$"
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 2 resolved / 2 findingsAdds input validation for governance workflow edge conditions and node references to prevent malformed Flowable expressions. Validation is enforced at the API boundary with clear 400 responses, guarded in expression construction, and defined via JSON schema patterns. All legitimate values across seed workflows continue to work; existing workflows with now-illegal names or conditions will be blocked on update, and empty-string conditions are rejected by the validator rather than treated as unconditional. 29 tests pass with no failures. ✅ 2 resolved✅ Edge Case: Existing workflows with now-illegal names/conditions blocked on update
✅ Quality: Empty-string condition rejected by validator but treated as unconditional
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (3)
openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowExpressionValidator.java:20
SAFE_NODE_REFERENCEcurrently allows node references starting with a digit (e.g.1node). Those will be interpolated into a JUEL variable position (${from_result ...}) and are likely to produce a syntactically invalid expression at runtime. Tighten the pattern so the first character is a letter or_(identifier-like).
// A conditional edge's source ('from') lands in code position as the JUEL variable-name prefix
// (${from_result == ...}); a valid variable reference is limited to identifier characters.
private static final Pattern SAFE_NODE_REFERENCE = Pattern.compile("^[A-Za-z0-9_]+$");
openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/WorkflowExpressionValidatorTest.java:63
- This test suite doesn’t currently cover the case where a node reference starts with a digit, which the validator should reject to avoid generating invalid JUEL variable references. Add a digit-leading example and rename the test to reflect the broader invalidity (not just disallowed characters).
@ParameterizedTest
@ValueSource(strings = {"a' b", "foo.bar", "node-1", "has space", "${x}"})
void rejectsNodeReferencesWithDisallowedCharacters(String reference) {
assertFalse(WorkflowExpressionValidator.isSafeNodeReference(reference));
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDefinitionRepository.java:229
- The error for an invalid conditional-edge
fromreference doesn’t include the rejected value, and (after tightening the regex) should also mention the “must start with letter or '_'” constraint to avoid confusion when debugging 400s.
throw BadRequestException.of(
String.format(
"Workflow '%s' conditional edge '%s' -> '%s' has an invalid source node reference; "
+ "allowed characters: letters, digits, '_'",
workflowName, edge.getFrom(), edge.getTo()));
|
|
Failed to cherry-pick changes to the 1.13 branch. |
|
Failed to cherry-pick changes to the 2.0 branch. |



Describe your changes
Governance workflow edge
conditionvalues and node references are used to build the Flowable sequence-flow expressions that drive conditional transitions (${from_result == 'condition'}). This PR restricts the values that are interpolated into those expressions so only well-formed input is accepted.WorkflowExpressionValidatorholding the allowed patterns (a condition must be empty — unconditional — or contain at least one alphanumeric plusspace . _ -; a conditional edge's source must be an identifier).WorkflowDefinitionRepository(rejected with a clear400). Unconditional edges are untouched, so node names keep the broaderentityNamecontract.Edgeas a defense-in-depth check.edge.json: add apattern/maxLengthoncondition(aligned with the server-side validator) andminLength/maxLengthbounds onfrom/to.Legitimate values used across all seed workflows (e.g.
approve,reject,true,false,ack,assign,resolve) continue to work unchanged.Type of change
Tests
WorkflowExpressionValidatorTest,EdgeTest, andWorkflowDefinitionRepositoryEdgeSafetyTest— 40 tests, all passing.201) while malformed conditions and source references are rejected (400), and an empty (unconditional) condition is accepted.Checklist