## Automated fix for [bug 6848](https://sonarly.com/issue/6848?type=bug) **Severity:** `critical` ### Summary WorkflowEditActionCodeFields.tsx calls Object.entries(functionInput) without a null guard on line 40, crashing when action.settings.input.logicFunctionInput is undefined. This happens because workflow version step data in the database may contain the old field name serverlessFunctionInput (from before the rename in commitda6f1bbef3), and no data migration was created to update JSON keys inside the steps JSONB column. ### User Impact Users viewing or editing a workflow version containing a CODE step that was created before the serverlessFunction-to-logicFunction rename see a crash. The page fails to render the workflow step detail panel, preventing them from viewing or modifying their workflow. ### Root Cause Proximate cause: Object.entries(functionInput) on line 40 of WorkflowEditActionCodeFields.tsx throws TypeError because functionInput is undefined. The stack trace confirms this: the crash occurs during React rendering (through scheduler -> react-dom render pipeline -> WorkflowEditActionCodeFields:40:15 -> Object.entries). 1. Why did Object.entries throw? Because the functionInput prop is undefined. It is initialized from action.settings.input.logicFunctionInput via useState on line 142 of WorkflowEditActionCode.tsx, with no fallback value. 2. Why is action.settings.input.logicFunctionInput undefined? Because the workflow version step data stored in the database JSONB steps column contains the OLD field name serverlessFunctionInput instead of logicFunctionInput. When the frontend accesses logicFunctionInput on the deserialized JSON object, it returns undefined. 3. Why does the database still have the old field name? Because commitda6f1bbef3(Rename serverlessFunction to logicFunction, Jan 28 2026) renamed the Zod schema field from serverlessFunctionInput to logicFunctionInput, and the database migration 1769556947746-renameServerless.ts only renames SQL tables and columns (serverlessFunction table to logicFunction, etc.) but does NOT update the JSON keys inside the steps JSONB column of the workflowVersion table. 4. Why was no JSON data migration created? The rename was a large-scale refactoring across the entire codebase. The steps column stores workflow action data as opaque JSON, and the migration only addressed relational schema changes (table/column renames) without updating the embedded JSON document structure. There is no upgrade command in 1-17, 1-18, or 1-19 directories that transforms the JSON keys from serverlessFunctionInput to logicFunctionInput. 5. Why did the component not handle this gracefully? The WorkflowEditActionCodeFields component has no null guard on the functionInput prop before calling Object.entries. Notably, the analogous WorkflowEditActionLogicFunction component DOES have a null guard on line 52 (action.settings.input.logicFunctionInput ?? {}), showing the team was aware of this possibility in one component but missed it in the other. **Introduced by:** martmull on 2026-02-16 in commit [`da064d5`](https://github.com/twentyhq/twenty/commit/da064d5e88a62939e0545a37c68381822e6932ef) ### Suggested Fix Two minimal null guards are added, matching the pattern already used in the analogous WorkflowEditActionLogicFunction component. First, in WorkflowEditActionCode.tsx the useState initializer is changed from action.settings.input.logicFunctionInput to action.settings.input.logicFunctionInput ?? {} so that functionInput is always an empty object rather than undefined when the DB record still uses the old serverlessFunctionInput key. Second, in WorkflowEditActionCodeFields.tsx the Object.entries call is changed from Object.entries(functionInput) to Object.entries(functionInput ?? {}) as a defensive guard at the render layer, ensuring the component renders safely even if an undefined value is passed from any caller. ### Evidence - **Code:** [packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx:142 - const [functionInput, setFunctionInput] =](https://github.com/twentyhq/twenty/blob/main/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx#L142) - **Code:** [packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCodeFields.tsx:40 - {Object.entries(functionInput ?? {}).map(([inputKey, inputValue]) => {](https://github.com/twentyhq/twenty/blob/main/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCodeFields.tsx#L40) --- *Generated by [Sonarly](https://sonarly.com)* Co-authored-by: Sonarly Claude Code <claude-code@sonarly.com>
The #1 Open-Source CRM
🌐 Website · 📚 Documentation · Roadmap ·
Discord ·
Figma
Installation
See: 🚀 Self-hosting 🖥️ Local Setup
Why Twenty
We built Twenty for three reasons:
CRMs are too expensive, and users are trapped. Companies use locked-in customer data to hike prices. It shouldn't be that way.
A fresh start is required to build a better experience. We can learn from past mistakes and craft a cohesive experience inspired by new UX patterns from tools like Notion, Airtable or Linear.
We believe in open-source and community. Hundreds of developers are already building Twenty together. Once we have plugin capabilities, a whole ecosystem will grow around it.
What You Can Do With Twenty
Please feel free to flag any specific needs you have by creating an issue.
Below are a few features we have implemented to date:
- Personalize layouts with filters, sort, group by, kanban and table views
- Customize your objects and fields
- Create and manage permissions with custom roles
- Automate workflow with triggers and actions
- Emails, calendar events, files, and more
Personalize layouts with filters, sort, group by, kanban and table views
Customize your objects and fields
Create and manage permissions with custom roles
Automate workflow with triggers and actions
Emails, calendar events, files, and more
Stack
- TypeScript
- Nx
- NestJS, with BullMQ, PostgreSQL, Redis
- React, with Jotai, Linaria and Lingui
Thanks
Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).
Join the Community
- Star the repo
- Subscribe to releases (watch -> custom -> releases)
- Follow us on Twitter or LinkedIn
- Join our Discord
- Improve translations on Crowdin
- Contributions are, of course, most welcome!




