Skip to content

fix: harden canvas node rendering and workflow mapper preparation#3899

Closed
forestileao wants to merge 18 commits intomainfrom
fix/nodes-errors-should-not-break-the-canvas
Closed

fix: harden canvas node rendering and workflow mapper preparation#3899
forestileao wants to merge 18 commits intomainfrom
fix/nodes-errors-should-not-break-the-canvas

Conversation

@forestileao
Copy link
Copy Markdown
Collaborator

@forestileao forestileao commented Apr 1, 2026

Summary

  • make workflowv2 node preparation resilient to mapper, additional-data, and custom-field failures
  • isolate canvas node render failures so a single broken node no longer breaks the whole canvas
  • extract workflowv2 node-preparation and canvas block logic into smaller utilities/modules

What Changed

  • added safe wrappers for additional-data builders and custom-field renderers
  • normalized malformed mapper output before it reaches ComponentBase and Trigger
  • moved trigger, component, composite, annotation, and group node preparation into dedicated workflowv2 lib files
  • added per-node error boundaries in CanvasPage
  • replaced the monolithic Block.tsx with a Block/ module split into index, types, content, data, and handles
  • made Block fall back safely for malformed or unknown node data instead of throwing
  • hardened componentBase against invalid arrays, invalid strings, and custom field render errors
  • added regression tests for safe mappers, workflow node preparation, block fallback rendering, and canvas node isolation
image

@superplanehq-integration
Copy link
Copy Markdown

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
@forestileao forestileao force-pushed the fix/nodes-errors-should-not-break-the-canvas branch from 5e3b9e6 to 82a51b3 Compare April 1, 2026 18:10
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
@forestileao forestileao marked this pull request as ready for review April 1, 2026 18:49
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
@superplane-policy-bot superplane-policy-bot bot requested a review from lucaspin April 1, 2026 19:20
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
@forestileao forestileao force-pushed the fix/nodes-errors-should-not-break-the-canvas branch from b626dc3 to 476ab84 Compare April 1, 2026 19:32
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@@ -0,0 +1 @@
export const CANVAS_NODE_FALLBACK_MESSAGE = "Can't display";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Weird that we have a dedicated file for this and not for other files. Why?

@shiroyasha
Copy link
Copy Markdown
Collaborator

IMHO, there are too many changes for this one pull-request to be able to provide high-quality feedback.

It is ok now, the code generally looks ok, but looking at this list, every one of them would be self-sufficient for its own PR:

  • added safe wrappers for additional-data builders and custom-field renderers
  • normalized malformed mapper output before it reaches ComponentBase and Trigger
  • moved trigger, component, composite, annotation, and group node preparation into dedicated workflowv2 lib files
  • added per-node error boundaries in CanvasPage
  • replaced the monolithic Block.tsx with a Block/ module split into index, types, content, data, and handles
  • made Block fall back safely for malformed or unknown node data instead of throwing
  • hardened componentBase against invalid arrays, invalid strings, and custom field render errors
  • added regression tests for safe mappers, workflow node preparation, block fallback rendering, and canvas node isolation

@forestileao
Copy link
Copy Markdown
Collaborator Author

@shiroyasha I don;t think we need that level of granularity because some changes depend on other's. But i am going to split this PR in more.
Closing by now

@forestileao forestileao closed this Apr 2, 2026
forestileao added a commit that referenced this pull request Apr 2, 2026
## Summary
- Add safe wrapper functions (`createSafeAdditionalDataBuilder`,
`createSafeCustomFieldRenderer`) and normalization
(`normalizeComponentBaseProps`, `normalizeTriggerProps`) so all mapper
output is sanitized before reaching the canvas
- Extract `findRegisteredComponentMapper` private helper to deduplicate
component lookup logic
- Add shared `@/lib/records` type guard utility and
`@/lib/canvas-node-fallback` fallback constant

## Context
Split from #3899. This is PR 1/3 — adds the error-handling foundation at
the data layer. PRs 2 and 3 depend on this.

<img width="2752" height="1086" alt="image"
src="https://github.com/user-attachments/assets/c8772f84-8c71-4428-a556-66cf9e0f61cc"
/>

---------

Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
forestileao added a commit that referenced this pull request Apr 2, 2026
## Summary
- Extract `prepareTriggerNode`, `prepareCompositeNode`,
`prepareComponentNode` from `index.tsx` into
`lib/canvas-node-preparation.ts`
- Extract annotation node preparation into
`lib/canvas-annotation-node.ts`
- Extract custom field rendering into
`lib/render-workflow-node-custom-field.ts`
- Add fallback node builders in `lib/canvas-node-fallback.ts` for
graceful degradation
- Rename `workflow-groups` to `canvas-groups` and add `prepareGroupNode`
+ `wireGroupParentChildRelationships`
- Extract `CANVAS_BUNDLE_ICON_SLUG`/`CANVAS_BUNDLE_COLOR` constants into
`lib/canvas-bundle.ts`
- Net reduction of ~420 lines from `index.tsx`

## Context
Split from #3899. This is PR 2/3, depends on #3916. Restructures the
data preparation layer without changing behavior.

---------

Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
forestileao added a commit that referenced this pull request Apr 2, 2026
## Summary
- Split monolithic `Block.tsx` (413 lines) into `Block/` module:
`types.ts`, `content.tsx`, `data.ts`, `handles.tsx`, and `index.tsx`
entry point
- Add `CanvasNodeErrorBoundary` that catches per-node render errors,
logs to Sentry, and displays a graceful fallback instead of crashing the
entire canvas
- Harden `componentBase` with input validation (`safeArray`,
`safeString`, wrapped customField calls)
- Replace `any` types with `unknown` throughout `CanvasPage/index.tsx`

## Context
Split from #3899. This is PR 3/3, depends on #3916. Independent of PR 2
(#3917).

---------

Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
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.

3 participants