alibaba/arthas · error · ApiException
parse request failed: request body is empty
Error message
parse request failed: request body is empty
What it means
Thrown by HttpApiHandler.parseRequest when the HTTP request body is blank (null, empty, or whitespace only). The Arthas HTTP API expects a JSON body containing at minimum an 'action' field; an empty body cannot be parsed into an ApiRequest.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java:105
logger.error("arthas process http api request error: " + request.uri() + ", request body: " + requestBody, e);
}
if (result == null) {
result = createResponse(ApiState.FAILED, "The request was not processed");
}
result.setRequestId(requestId);
byte[] jsonBytes = JSON.toJSONBytes(result, JSON_FILTERS);
// create http response
DefaultFullHttpResponse response = new DefaultFullHttpResponse(request.protocolVersion(),
HttpResponseStatus.OK, Unpooled.wrappedBuffer(jsonBytes));
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/json; charset=utf-8");
return response;
}
private ApiRequest parseRequest(String requestBody) throws ApiException {
if (StringUtils.isBlank(requestBody)) {
throw new ApiException("parse request failed: request body is empty");
}
try {
//ObjectMapper objectMapper = new ObjectMapper();
//return objectMapper.readValue(requestBody, ApiRequest.class);
return JSON.parseObject(requestBody, ApiRequest.class);
} catch (Exception e) {
throw new ApiException("parse request failed: " + e.getMessage(), e);
}
}
private ApiResponse processRequest(ChannelHandlerContext ctx, ApiRequest apiRequest) {
String actionStr = apiRequest.getAction();
try {
if (StringUtils.isBlank(actionStr)) {
throw new ApiException("'action' is required");
}
ApiAction action;View on GitHub (pinned to 21cf2e9ba5)
Solutions
- Send a valid JSON body: curl -X POST http://localhost:8563/api -d '{"action":"init_session"}'.
- Ensure the client sets Content-Type: application/json and includes a non-empty body.
- Check that no intermediary proxy strips POST bodies.
Example fix
# before
curl -X POST http://localhost:8563/api
# -> parse request failed: request body is empty
# after
curl -X POST http://localhost:8563/api \
-H 'Content-Type: application/json' \
-d '{"action":"init_session"}' Defensive patterns
Strategy: validation
Validate before calling
// Client-side: ensure non-empty body before sending
String body = buildRequestBody(apiRequest);
if (body == null || body.trim().isEmpty()) {
throw new IllegalArgumentException("Request body must not be empty");
} Prevention
- Always include a -d/--data flag with valid JSON when POSTing to the API.
- Set Content-Type: application/json on all API requests.
When it happens
Trigger: POSTing to the Arthas HTTP API endpoint (default :8563) with an empty request body, or sending a request with Content-Length: 0.
Common situations: Misconfigured REST client that omits the body. Curl invocation missing the -d flag. Proxy or load balancer stripping the body.
Related errors
- parse request failed: {}
- 'action' is required
- 'sessionId' is required
- 'consumerId' is required
- Conversion from JSON to {type} failed
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/d113538b5277d4da.
Report an issue: GitHub.