alibaba/arthas · error · ApiException

'consumerId' is required

Error message

'consumerId' is required

What it means

Thrown by processPullResultsRequest when the 'consumerId' field is blank. Pulling results requires a consumerId (obtained during INIT_SESSION or JOIN_SESSION) to identify which result consumer's queue to poll. Without it Arthas cannot locate the result stream.

Source

Thrown at core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java:494

        Map<String, Object> body = new TreeMap<String, Object>();
        body.put("jobId", job.id());
        body.put("jobStatus", job.status());
        return new ApiResponse()
                .setState(ApiState.SUCCEEDED)
                .setBody(body);
    }

    /**
     * Pull results from result queue
     *
     * @param apiRequest
     * @param session
     * @return
     */
    private ApiResponse processPullResultsRequest(ApiRequest apiRequest, Session session) throws ApiException {
        String consumerId = apiRequest.getConsumerId();
        if (StringUtils.isBlank(consumerId)) {
            throw new ApiException("'consumerId' is required");
        }
        ResultConsumer consumer = null;
        SharingResultDistributor resultDistributor = session.getResultDistributor();
        if (resultDistributor != null) {
            consumer = resultDistributor.getConsumer(consumerId);
        }
        if (consumer == null) {
            throw new ApiException("consumer not found: " + consumerId);
        }

        List<ResultModel> results = consumer.pollResults();
        Map<String, Object> body = new TreeMap<String, Object>();
        body.put("results", results);

        ApiResponse response = new ApiResponse();
        response.setState(ApiState.SUCCEEDED)
                .setSessionId(session.getSessionId())
                .setConsumerId(consumerId)

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Capture the consumerId from the INIT_SESSION or JOIN_SESSION response and include it in every PULL_RESULTS request.
  2. Ensure the JSON key is exactly 'consumerId' (case-sensitive).

Example fix

// before
{"action": "pull_results", "sessionId": "<sid>"}
// -> 'consumerId' is required

// after
{"action": "pull_results", "sessionId": "<sid>", "consumerId": "<from init_session>"}
Defensive patterns

Strategy: validation

Validate before calling

// Client-side: ensure consumerId is present for PULL_RESULTS
if ("PULL_RESULTS".equalsIgnoreCase(action) &&
        (consumerId == null || consumerId.trim().isEmpty())) {
    throw new IllegalArgumentException("'consumerId' is required for PULL_RESULTS");
}

Type guard

boolean hasConsumerId(ApiRequest req) {
    String c = req.getConsumerId();
    return c != null && !c.trim().isEmpty();
}

Prevention

When it happens

Trigger: Calling PULL_RESULTS without a consumerId in the request body, or with consumerId set to empty string.

Common situations: Client forgets to store the consumerId returned by INIT_SESSION/JOIN_SESSION. New client integration that omits the field.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/a163ed2bbdd7242d. Report an issue: GitHub.