Skip to content

Commit 12f76b1

Browse files
committed
fix: validate JSON object in form submission
1 parent b2999dc commit 12f76b1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ui/src/views/tool/McpToolFormDrawer.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ const submit = async (formEl: FormInstance | undefined) => {
246246
await formEl.validate((valid: any) => {
247247
if (valid) {
248248
try {
249-
JSON.parse(form.value.code as string)
249+
const parsed = JSON.parse(form.value.code as string)
250+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
251+
throw new Error('Code must be a valid JSON object')
252+
}
250253
} catch (e) {
251254
MsgError(t('views.applicationWorkflow.nodes.mcpNode.mcpServerTip'))
252255
return

0 commit comments

Comments
 (0)