Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Jan 9, 2026

Add Support for Step Condition Modes in Flow Shape Comparison

This PR enhances the flow shape comparison functionality to include whenUnmet and whenFailed condition modes. These condition modes are structural properties that affect DAG execution semantics and must match between worker and database definitions.

Key changes:

  • Updated _compare_flow_shapes function to detect differences in whenUnmet and whenFailed values
  • Modified _create_flow_from_shape to properly handle condition modes when creating flows
  • Enhanced _get_flow_shape to include condition modes in the returned shape
  • Updated the TypeScript flow shape definitions to include condition modes as structural properties
  • Added comprehensive tests to verify condition mode handling in flow shapes

These changes ensure that when a flow is deployed, the condition modes are properly compared and any differences are detected, preventing potential execution inconsistencies between the worker and database definitions.

@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

⚠️ No Changeset found

Latest commit: be73fb9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud
Copy link

nx-cloud bot commented Jan 9, 2026

View your CI Pipeline Execution ↗ for commit be73fb9

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 3m 49s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗
nx run edge-worker:e2e ✅ Succeeded 48s View ↗
nx run client:e2e ✅ Succeeded 1m 9s View ↗
nx run core:pgtap ✅ Succeeded 1m 5s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 3s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 3s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 25s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-11 19:49:34 UTC

@jumski jumski force-pushed the 01-09-pgf-3hs.13_unify_flow_compilation_paths_via_flowshape branch from 6824bcf to 919577f Compare January 9, 2026 14:20
Comment on lines +51 to +52
when_unmet => v_step->>'whenUnmet',
when_failed => v_step->>'whenFailed'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical NULL handling bug: When whenUnmet or whenFailed fields are missing from the JSON shape, v_step->>'whenUnmet' returns NULL. Explicitly passing NULL to add_step() will attempt to insert NULL into a NOT NULL column, causing a constraint violation.

-- Fix by using COALESCE to apply defaults:
when_unmet => COALESCE(v_step->>'whenUnmet', 'skip'),
when_failed => COALESCE(v_step->>'whenFailed', 'fail')

This will fail when processing old shapes or malformed data that don't include these new fields. SQL function defaults only apply when parameters are omitted, not when NULL is explicitly passed.

Suggested change
when_unmet => v_step->>'whenUnmet',
when_failed => v_step->>'whenFailed'
when_unmet => COALESCE(v_step->>'whenUnmet', 'skip'),
when_failed => COALESCE(v_step->>'whenFailed', 'fail')

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +248 to +249
when_unmet => v_step->>'whenUnmet',
when_failed => v_step->>'whenFailed'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical NULL handling bug: Same issue as in 0100_function_create_flow_from_shape.sql. When JSON fields are missing, v_step->>'whenUnmet' returns NULL. Explicitly passing NULL bypasses the parameter defaults and will violate the NOT NULL constraint on the when_unmet and when_failed columns.

-- Fix by using COALESCE:
when_unmet => COALESCE(v_step->>'whenUnmet', 'skip'),
when_failed => COALESCE(v_step->>'whenFailed', 'fail')

This creates a production risk during deployment or when processing legacy shapes.

Suggested change
when_unmet => v_step->>'whenUnmet',
when_failed => v_step->>'whenFailed'
when_unmet => COALESCE(v_step->>'whenUnmet', 'skip'),
when_failed => COALESCE(v_step->>'whenFailed', 'fail')

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jumski jumski force-pushed the 01-09-pgf-3hs.13_unify_flow_compilation_paths_via_flowshape branch from 919577f to be73fb9 Compare January 11, 2026 19:26
@jumski jumski force-pushed the 01-08-implement_ifnot_negative_condition_pattern branch from 4354fcb to 3f4ff52 Compare January 11, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants