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 context

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Read the body text in the error message and fix the JSON syntax around the failing variable
  2. Quote string variables in the template ("${var}") or ensure values are JSON-encoded before substitution
  3. Validate the template with sample variable values before publishing the workflow
  4. 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

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.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/31888987af8011bb. Report an issue: GitHub.