Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: improve boolean field handling in plugin configuration forms (#23160)

Alan Bustamantec33741a5e959
diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx
index 130773e0c2e..a715237a43b 100644
--- a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx
@@ -47,7 +47,22 @@ const EndpointModal: FC<Props> = ({
return
}
}
- onSaved(tempCredential)
+
+ // Fix: Process boolean fields to ensure they are sent as proper boolean values
+ const processedCredential = { ...tempCredential }
+ formSchemas.forEach((field) => {
+ if (field.type === 'boolean' && processedCredential[field.name] !== undefined) {
+ const value = processedCredential[field.name]
+ if (typeof value === 'string')
+ processedCredential[field.name] = value === 'true' || value === '1' || value === 'True'
+ else if (typeof value === 'number')
+ processedCredential[field.name] = value === 1
+ else if (typeof value === 'boolean')
+ processedCredential[field.name] = value
+ }
+ })
+
+ onSaved(processedCredential)
}
return (
diff --git a/web/app/components/tools/utils/to-form-schema.ts b/web/app/components/tools/utils/to-form-schema.ts
index ee7f3379ade..ae43e6f157a 100644
--- a/web/app/components/tools/utils/to-form-schema.ts
+++ b/web/app/components/tools/utils/to-form-schema.ts
@@ -63,6 +63,16 @@ export const addDefaultValue = (value: Record<string, any>, formSchemas: { varia
const itemValue = value[formSchema.variable]
if ((formSchema.default !== undefined) && (value === undefined || itemValue === null || itemValue === '' || itemValue === undefined))
newValues[formSchema.variable] = formSchema.default
+
+ // Fix: Convert boolean field values to proper boolean type
+ if (formSchema.type === 'boolean' && itemValue !== undefined && itemValue !== null && itemValue !== '') {
+ if (typeof itemValue === 'string')
+ newValues[formSchema.variable] = itemValue === 'true' || itemValue === '1' || itemValue === 'True'
+ else if (typeof itemValue === 'number')
+ newValues[formSchema.variable] = itemValue === 1
+ else if (typeof itemValue === 'boolean')
+ newValues[formSchema.variable] = itemValue
+ }
})
return newValues
}