alibaba/spring-ai-alibaba · error · BizException
WORKFLOW_EXECUTE_ERROR
WORKFLOW_EXECUTE_ERROR
Error message
Invalid JSON format data, body:${data} What it means
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.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/workflow/processor/impl/APIExecuteProcessor.java:275
String type = MapUtils.getString(body, "type");
Map<String, Object> params = Maps.newHashMap();
if ("form-data".equalsIgnoreCase(type)) {
Object o = body.get("data");
List<Node.InputParam> data = JsonUtils.fromJsonToList(JsonUtils.toJson(o), Node.InputParam.class);
data.forEach(param -> {
Object valueFromRequestContext = VariableUtils.getValueStringFromContext(param, context);
params.put(param.getKey(), valueFromRequestContext);
});
}
else if ("json".equalsIgnoreCase(type)) {
String data = MapUtils.getString(body, "data");
Set<String> keys = VariableUtils.identifyVariableSetFromText(data);
Map<String, Object> map = constructBodyParamsMap(keys, context);
data = constructData(keys, map, data);
boolean validJSON = JsonUtils.isValidJson(data);
if (!validJSON) {
log.info("log used for query jsonFormatData:{} ,requestID:{}", data, context.getRequestId());
throw new BizException(
ErrorCode.WORKFLOW_EXECUTE_ERROR.toError("Invalid JSON format data, body:" + data));
}
params.put("json", data);
}
else if ("raw".equalsIgnoreCase(type)) {
String data = MapUtils.getString(body, "data");
Set<String> keys = VariableUtils.identifyVariableSetFromText(data);
Map<String, Object> map = constructBodyParamsMap(keys, context);
data = constructData(keys, map, data);
params.put("raw", data);
}
return params;
}
/**
* Build variable value map from contextView on GitHub (pinned to f82da0b50f)
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
Example fix
// before
{"name": ${name}, "age": }
// after
{"name": "${name}", "age": 18} Defensive patterns
Strategy: validation
Validate before calling
String rendered = renderTemplate(bodyTemplate, contextVars);
if (!JsonUtils.isValidJson(rendered)) {
throw new IllegalStateException("Body template renders to invalid JSON: " + rendered);
} Try / catch
try {
processor.execute(graph, node, context);
} catch (BizException e) {
if (ErrorCode.WORKFLOW_EXECUTE_ERROR.getCode().equals(e.getCode()) && e.getMessage().startsWith("Invalid JSON format data")) {
log.error("Fix body template; rendered body: {}", e.getMessage());
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Variable references resolve to null/empty leaving trailing commas; user pasted a non-JSON body; variable values contain unescaped quotes breaking the JSON string.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- INVALID_PARAMS
- MISSING_PARAMS
- 变量替换失败,使用原始模板: template={}, variables={}
- Oauth2CallError
- CreateMCPServerError
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/31888987af8011bb.
Report an issue: GitHub.