{"record":{"id":"8ef63084ee5753c6","repo":"alibaba/arthas","slug":"consumer-not-found","errorCode":null,"errorMessage":"consumer not found: {}","messagePattern":"consumer not found: (.+?)","errorType":"http","errorClass":"ApiException","httpStatus":200,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java","lineNumber":502,"sourceCode":"    /**\n     * Pull results from result queue\n     *\n     * @param apiRequest\n     * @param session\n     * @return\n     */\n    private ApiResponse processPullResultsRequest(ApiRequest apiRequest, Session session) throws ApiException {\n        String consumerId = apiRequest.getConsumerId();\n        if (StringUtils.isBlank(consumerId)) {\n            throw new ApiException(\"'consumerId' is required\");\n        }\n        ResultConsumer consumer = null;\n        SharingResultDistributor resultDistributor = session.getResultDistributor();\n        if (resultDistributor != null) {\n            consumer = resultDistributor.getConsumer(consumerId);\n        }\n        if (consumer == null) {\n            throw new ApiException(\"consumer not found: \" + consumerId);\n        }\n\n        List<ResultModel> results = consumer.pollResults();\n        Map<String, Object> body = new TreeMap<String, Object>();\n        body.put(\"results\", results);\n\n        ApiResponse response = new ApiResponse();\n        response.setState(ApiState.SUCCEEDED)\n                .setSessionId(session.getSessionId())\n                .setConsumerId(consumerId)\n                .setBody(body);\n        return response;\n    }\n\n    private boolean waitForJob(Job job, int timeout) {\n        long startTime = System.currentTimeMillis();\n        while (true) {\n            switch (job.status()) {","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java#L484-L520","documentation":"Thrown by the HTTP API when a pull-results request references a consumerId that is not registered with the session's SharingResultDistributor. Each Arthas HTTP API session maintains a set of ResultConsumer instances keyed by consumerId; pulling results requires a previously created consumer. If the session has no distributor or the distributor has no consumer for that ID, this error fires.","triggerScenarios":"Calling the /api/v1/pullResults (or equivalent) HTTP endpoint with a consumerId that was never created via a prior consumer-registration call, or using a consumerId from a different/expired session, or after the session's ResultDistributor was set to null.","commonSituations":"The client polled results before subscribing/creating a consumer; the session timed out and the distributor was torn down; a consumerId was typo'd or copy-pasted from another session; the HTTP API client retried after a session reconnect without re-registering its consumer.","solutions":["Ensure a consumer is created (PullResultsHandler / consumer registration) for this consumerId before issuing pull requests within the same session.","Verify the consumerId in the request matches the one returned when the consumer was created and that the sessionId is still valid.","If the session expired, re-create the session and re-register the consumer, then retry the pull.","Check that session.getResultDistributor() is non-null — if the session was created without result distribution enabled, switch to a session type that supports it."],"exampleFix":"// before: polling without registering a consumer\nApiRequest req = new ApiRequest();\nreq.setConsumerId(\"my-consumer\");\npullResults(req); // throws 'consumer not found'\n\n// after: register consumer first, then poll\nString consumerId = session.getResultDistributor().createConsumer();\nreq.setConsumerId(consumerId);\npullResults(req);","handlingStrategy":"validation","validationCode":"// Validate consumer exists before pulling\nSharingResultDistributor distributor = session.getResultDistributor();\nif (distributor == null || distributor.getConsumer(consumerId) == null) {\n    // re-register consumer or return a friendly error to the client\n    consumerId = distributor.createConsumer();\n}\npullResults(consumerId);","typeGuard":null,"tryCatchPattern":"try {\n    pullResults(apiRequest);\n} catch (ApiException e) {\n    if (e.getMessage().contains(\"consumer not found\")) {\n        // re-create consumer and retry once\n        String newConsumerId = session.getResultDistributor().createConsumer();\n        apiRequest.setConsumerId(newConsumerId);\n        pullResults(apiRequest);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always create a consumer immediately after session creation and store the consumerId alongside the sessionId.","Re-register consumers after any session reconnect or expiry."],"tags":["arthas","http-api","session","consumer"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}