fix: harden canvas node rendering and workflow mapper preparation#3899
fix: harden canvas node rendering and workflow mapper preparation#3899forestileao wants to merge 18 commits intomainfrom
Conversation
|
👋 Commands for maintainers:
|
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>
5e3b9e6 to
82a51b3
Compare
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>
b626dc3 to
476ab84
Compare
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
web_src/src/pages/workflowv2/lib/render-workflow-node-custom-field.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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"; | |||
There was a problem hiding this comment.
Weird that we have a dedicated file for this and not for other files. Why?
|
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:
|
|
@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. |
## 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>
## 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>
## 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>

Summary
What Changed
ComponentBaseandTriggerCanvasPageBlock.tsxwith aBlock/module split intoindex,types,content,data, andhandlesBlockfall back safely for malformed or unknown node data instead of throwingcomponentBaseagainst invalid arrays, invalid strings, and custom field render errors