Fix array-typed parameters in code/logic-function action forms (#21102)

## Problem

`any[]` type prevented value input:
<img width="544" height="349" alt="Screenshot 2026-06-01 at 14 08 47"
src="https://github.com/user-attachments/assets/956238d0-6fea-4be1-b75a-ab0e6e6424ac"
/>

In the workflow Code action (and the Logic Function action), parameters
typed as any[], string[], etc. rendered as an empty grey box instead of
an "Enter value" text input. After any debounced save, even a properly
initialised array field would also collapse into an empty container.

The Array<T> / ReadonlyArray<T> generic form fell through to a generic
text input by accident (which "looked" right, but for the wrong reason —
no schema info downstream).

## Root causes
Three places treated arrays as plain objects via @sniptt/guards'
isObject (which is true for arrays):

1. WorkflowEditActionCodeFields.tsx — arrays went into the nested-fields
branch; Object.entries([]) is empty → empty container, no placeholder.
2. mergeDefaultFunctionInputAndFunctionInput.ts — recursed into arrays
during merge, turning [] into {}. Triggered on every debounced save, so
the bug surfaced after any edit.
3. get-function-input-schema.ts — only handled T[]
(SyntaxKind.ArrayType); Array<T> (SyntaxKind.TypeReference) was
unrecognised, so the form lost any item-type info.
This commit is contained in:
Marie
2026-06-01 15:14:46 +02:00
committed by GitHub
parent da5e1152bb
commit 66afd5a1de
6 changed files with 127 additions and 7 deletions
@@ -1,3 +1,4 @@
import { type InputJsonSchema } from '@/logic-function';
import { getFunctionInputFromInputSchema, type InputSchema } from '@/workflow';
describe('getDefaultFunctionInputFromInputSchema', () => {
@@ -40,4 +41,19 @@ describe('getDefaultFunctionInputFromInputSchema', () => {
expectedResult,
);
});
it('should init arrays with unknown items (e.g. any[]) as empty arrays', () => {
const inputSchema: InputJsonSchema[] = [
{
type: 'object',
properties: {
briefs: { type: 'array', items: {} },
},
},
];
expect(getFunctionInputFromInputSchema(inputSchema)).toEqual([
{ briefs: [] },
]);
});
});