From 666f3e5577a573da3ce6a72d65d625ed1a523f92 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 20 Nov 2026 08:42:58 +0100 Subject: [PATCH] fix: send null for untouched nullable inputs in run forms (#12553) * fix: send null for untouched nullable inputs in run forms * fix: fill nullable defaults only in forms submitted as run args * fix: keep the nullable opt-out through nested object forms --- frontend/src/lib/components/ArgInput.svelte | 24 +++++++++++++++++++ frontend/src/lib/components/SchemaForm.svelte | 5 ++++ .../components/schema/SchemaFormDND.svelte | 5 +++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index bfc3c81cc0..3abe981f72 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -98,6 +98,12 @@ customErrorMessage?: string | undefined onlyMaskPassword?: boolean nullable?: boolean + /** + * Write null into an untouched nullable string/list field. Only for forms whose value is + * submitted as run args: elsewhere an undefined value has its own meaning (an unset schema + * default, a step input still following its expression) that a written null would override. + */ + fillNullableDefault?: boolean title?: string | undefined placeholder?: string | undefined order?: string[] | undefined @@ -171,6 +177,7 @@ customErrorMessage = undefined, onlyMaskPassword = false, nullable = false, + fillNullableDefault = false, title = $bindable(undefined), placeholder = $bindable(undefined), order = $bindable(undefined), @@ -301,8 +308,19 @@ } } + // A nullable field's default is a real null: left undefined, the key is dropped + // from the submitted args and the runnable never receives it. + const unsetNullable = + fillNullableDefault && + nnullable && + value === undefined && + !ignoreValueUndefined && + (inputCat === 'string' || inputCat === 'list') if (nnullable && type === 'string' && value === '' && nvalue == null) { value = null + } else if (unsetNullable && nvalue == null) { + value = null + lastValue = value } else if (nvalue != null && !deepEqual(nvalue, value)) { value = nvalue lastValue = value @@ -867,6 +885,7 @@
| undefined } @@ -123,6 +125,7 @@ computeS3ForceViewerPolicies = undefined, workspace = undefined, chatInputEnabled = false, + fillNullableDefault = true, actions: actions_render = undefined }: Props = $props() @@ -363,6 +366,7 @@ simpleTooltip={schemaFieldTooltip[argName]} {onlyMaskPassword} nullable={formerProperty?.nullable} + {fillNullableDefault} title={formerProperty?.title} placeholder={formerProperty?.placeholder} orderEditable={dndConfig != undefined} @@ -444,6 +448,7 @@ simpleTooltipWarning={argName in schemaFieldWarnings} {onlyMaskPassword} nullable={prop?.nullable} + {fillNullableDefault} title={prop?.title} placeholder={prop?.placeholder} orderEditable={dndConfig != undefined} diff --git a/frontend/src/lib/components/schema/SchemaFormDND.svelte b/frontend/src/lib/components/schema/SchemaFormDND.svelte index 21399f775b..4c66c77258 100644 --- a/frontend/src/lib/components/schema/SchemaFormDND.svelte +++ b/frontend/src/lib/components/schema/SchemaFormDND.svelte @@ -27,6 +27,7 @@ dndType?: string lightHeaderFont?: boolean workspace?: string | undefined + fillNullableDefault?: boolean } let { @@ -48,7 +49,8 @@ className = '', dndType = generateRandomString(), lightHeaderFont, - workspace = undefined + workspace = undefined, + fillNullableDefault = true }: Props = $props() $effect.pre(() => { @@ -138,6 +140,7 @@ {onlyMaskPassword} {disablePortal} {disabled} + {fillNullableDefault} {helperScript} {className} bind:schema