{"record":{"id":"31888987af8011bb","repo":"alibaba/spring-ai-alibaba","slug":"workflow-execute-error","errorCode":"WORKFLOW_EXECUTE_ERROR","errorMessage":"Invalid JSON format data, body:${data}","messagePattern":"Invalid JSON format data, body:(.+?)","errorType":"error_code","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/workflow/processor/impl/APIExecuteProcessor.java","lineNumber":275,"sourceCode":"\t\tString type = MapUtils.getString(body, \"type\");\n\t\tMap<String, Object> params = Maps.newHashMap();\n\t\tif (\"form-data\".equalsIgnoreCase(type)) {\n\t\t\tObject o = body.get(\"data\");\n\t\t\tList<Node.InputParam> data = JsonUtils.fromJsonToList(JsonUtils.toJson(o), Node.InputParam.class);\n\t\t\tdata.forEach(param -> {\n\t\t\t\tObject valueFromRequestContext = VariableUtils.getValueStringFromContext(param, context);\n\t\t\t\tparams.put(param.getKey(), valueFromRequestContext);\n\t\t\t});\n\t\t}\n\t\telse if (\"json\".equalsIgnoreCase(type)) {\n\t\t\tString data = MapUtils.getString(body, \"data\");\n\t\t\tSet<String> keys = VariableUtils.identifyVariableSetFromText(data);\n\t\t\tMap<String, Object> map = constructBodyParamsMap(keys, context);\n\t\t\tdata = constructData(keys, map, data);\n\t\t\tboolean validJSON = JsonUtils.isValidJson(data);\n\t\t\tif (!validJSON) {\n\t\t\t\tlog.info(\"log used for query jsonFormatData:{} ,requestID:{}\", data, context.getRequestId());\n\t\t\t\tthrow new BizException(\n\t\t\t\t\t\tErrorCode.WORKFLOW_EXECUTE_ERROR.toError(\"Invalid JSON format data, body:\" + data));\n\t\t\t}\n\t\t\tparams.put(\"json\", data);\n\n\t\t}\n\t\telse if (\"raw\".equalsIgnoreCase(type)) {\n\t\t\tString data = MapUtils.getString(body, \"data\");\n\t\t\tSet<String> keys = VariableUtils.identifyVariableSetFromText(data);\n\t\t\tMap<String, Object> map = constructBodyParamsMap(keys, context);\n\t\t\tdata = constructData(keys, map, data);\n\t\t\tparams.put(\"raw\", data);\n\t\t}\n\n\t\treturn params;\n\t}\n\n\t/**\n\t * Build variable value map from context","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/workflow/processor/impl/APIExecuteProcessor.java#L257-L293","documentation":"APIExecuteProcessor.buildBodyFormParams() (json body mode) substitutes context variables into the body template and then validates the result with JsonUtils.isValidJson(). If the rendered body is not valid JSON, it throws BizException WORKFLOW_EXECUTE_ERROR including the offending body text.","triggerScenarios":"An HTTP node configured with body type 'json' whose template, after variable substitution, is not parseable JSON — e.g. missing braces, unquoted values, a variable expanding to raw text or empty string.","commonSituations":"Variable references resolve to null/empty leaving trailing commas; user pasted a non-JSON body; variable values contain unescaped quotes breaking the JSON string.","solutions":["Read the body text in the error message and fix the JSON syntax around the failing variable","Quote string variables in the template (\"${var}\") or ensure values are JSON-encoded before substitution","Validate the template with sample variable values before publishing the workflow","Switch the body type to 'raw' if the payload is intentionally not JSON"],"exampleFix":"// before\n{\"name\": ${name}, \"age\": }\n// after\n{\"name\": \"${name}\", \"age\": 18}","handlingStrategy":"validation","validationCode":"String rendered = renderTemplate(bodyTemplate, contextVars);\nif (!JsonUtils.isValidJson(rendered)) {\n    throw new IllegalStateException(\"Body template renders to invalid JSON: \" + rendered);\n}","typeGuard":null,"tryCatchPattern":"try {\n    processor.execute(graph, node, context);\n} catch (BizException e) {\n    if (ErrorCode.WORKFLOW_EXECUTE_ERROR.getCode().equals(e.getCode()) && e.getMessage().startsWith(\"Invalid JSON format data\")) {\n        log.error(\"Fix body template; rendered body: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Always quote string substitutions inside JSON templates","Test the HTTP node with sample variable values before publishing","Prefer structured body builders over raw string templates","Escape or JSON-encode variable values that may contain quotes"],"tags":["http","json","workflow","template"],"backgroundTag":"json-parse-error","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}