Skip to content

fix: graceful degradation — skip unknown step types / transform ops instead of crashing#81

Merged
rdwr-taly merged 2 commits into
mainfrom
fix/js-graceful-degradation
Jul 1, 2026
Merged

fix: graceful degradation — skip unknown step types / transform ops instead of crashing#81
rdwr-taly merged 2 commits into
mainfrom
fix/js-graceful-degradation

Conversation

@rdwr-taly

Copy link
Copy Markdown
Collaborator

Summary

Cross-app parity with the flowrunner-cli graceful-degradation fix. The FlowRunner UI engine had the same two forward-compatibility failures, so a flow authored with a newer/unknown step type or transform op behaved badly on an older UI.

Fix

  • Unknown step type (flowRunner.js): previously threw → the whole run halted. Now yields { status: 'skipped', unsupported: true } + a user-visible warning, and the flow continues.
  • Unknown transform op (transformOps.js): previously silently downgraded to base64_decode (ran the wrong operation). Now skipped, recorded in executeTransformOps' warnings[] (structured entry + a TRANSFORM_OP_UNSUPPORTED marker), and surfaced by the transform step; the op's output variable is left unset.
  • normalizeTransformOp is intentionally left tolerant because the editor (flowStepComponents.js) calls it — making it throw would break opening a flow that contains a newer op.

Tests + harness

  • 2 new unit tests (TDD, RED → GREEN): op-level skip / no-downgrade, and step-level skip / no-halt.
  • Also fixes the completely broken Jest harness: __tests__/setup.js require()d the vendored UMD drawflow.min.js, which Node treats as ESM under the app's root "type": "module", so npm test loaded zero tests. (CI never caught it — build.yml runs only npm run dist.) Added assets/vendor/drawflow/package.json ("type": "commonjs") scoping just that vendored dir to CJS; the browser loads Drawflow via a <script> tag, so runtime is unaffected. Suite now runs: 122 passing.

Known follow-ups (NOT this PR)

  • The harness fix unmasked 4 pre-existing flowVisualizer.test.js failures (Drawflow drag / double-click / add-step under jsdom). Verified pre-existing (they fail with this PR's production changes stashed), tracked separately.
  • The editor (flowStepComponents.js:911) still rewrites an unknown op to base64_decode on open — a separate forward-compat item (see docs/flowmap-evolution.md).

🤖 Generated with Claude Code

rdwr-taly and others added 2 commits July 1, 2026 11:43
…f crashing

Cross-app parity with the flowrunner-cli fix. The JS engine had the same
two forward-compat failures:
- flowRunner.js threw on an unknown step type -> the whole run halted.
- transformOps.js silently downgraded an unknown transform op to
  base64_decode -> the wrong operation executed.

Both now degrade gracefully (skip-with-machine-readable-warning, continue):
- Unknown step type -> {status:'skipped', unsupported:true} + a user warning.
- Unknown transform op -> recorded in executeTransformOps' warnings[]
  (TRANSFORM_OP_UNSUPPORTED marker), surfaced by the transform step; the op's
  output var is left unset. normalizeTransformOp is left tolerant because the
  editor (flowStepComponents.js) also calls it.

Also fixes the Jest harness: setup.js require()d the vendored UMD
drawflow.min.js, unloadable under the app's "type":"module", so npm test was
fully broken (CI never runs it). Added a CommonJS marker package.json in the
vendored dir. This unblocked the suite (122 passing) and revealed 4
pre-existing flowVisualizer.test.js failures (tracked separately).

Adds 2 unit tests (RED->GREEN). Bible updated (changelog + gotchas).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All 4 failures were test-setup/isolation issues, not bugs in
flowVisualizer.js. flowVisualizer.js is unchanged.

- "node moved event triggers layout update callback": the nodeMoved
  handler treats the node element's style.left/top as authoritative
  (a real Drawflow drag updates both the data model's pos_x/pos_y AND
  the DOM element's style.left/top in lock-step). The test only mutated
  the data model, so the handler kept reading the stale rendered
  position (100,100). Fixed the test to also set the element's
  style.left/top, matching a real drag. Assertion unchanged.

- "dragging a node updates flow model layout": same DOM-vs-data-model
  issue as above. Additionally, this test created a second
  FlowVisualizer without destroying the beforeEach one, leaking that
  visualizer's .node-editor-modal into document.body and breaking the
  two tests below. Fixed by destroying the old visualizer first and by
  moving the DOM element alongside the data model. Assertions unchanged.

- "double-click opens node editor modal": passed document.querySelector
  ('.node-editor-modal'), which returned a leaked stale modal (display
  "none") from the drag test instead of the current visualizer's modal
  (display "flex"). Fixed by querying visualizer.nodeEditorModal
  directly. Assertions unchanged.

- "add step button triggers add-step callback": same leaked-modal
  problem via document.querySelector('.node-editor-add') — it grabbed a
  stale, unwired button. Fixed by querying the button within
  visualizer.nodeEditorModal. Assertions unchanged.

Full suite: 126 passed, 0 skipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rdwr-taly
rdwr-taly merged commit 584d728 into main Jul 1, 2026
3 checks passed
@rdwr-taly
rdwr-taly deleted the fix/js-graceful-degradation branch July 2, 2026 07:05
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.

1 participant