{"record":{"id":"72029ac813e1f8f4","repo":"alibaba/arthas","slug":"action-is-required-72029a","errorCode":null,"errorMessage":"'action' is required","messagePattern":"'action' is required","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":121,"sourceCode":"    private ApiRequest parseRequest(String requestBody) throws ApiException {\n        if (StringUtils.isBlank(requestBody)) {\n            throw new ApiException(\"parse request failed: request body is empty\");\n        }\n        try {\n            //ObjectMapper objectMapper = new ObjectMapper();\n            //return objectMapper.readValue(requestBody, ApiRequest.class);\n            return JSON.parseObject(requestBody, ApiRequest.class);\n        } catch (Exception e) {\n            throw new ApiException(\"parse request failed: \" + e.getMessage(), e);\n        }\n    }\n\n    private ApiResponse processRequest(ChannelHandlerContext ctx, ApiRequest apiRequest) {\n\n        String actionStr = apiRequest.getAction();\n        try {\n            if (StringUtils.isBlank(actionStr)) {\n                throw new ApiException(\"'action' is required\");\n            }\n            ApiAction action;\n            try {\n                action = ApiAction.valueOf(actionStr.trim().toUpperCase());\n            } catch (IllegalArgumentException e) {\n                throw new ApiException(\"unknown action: \" + actionStr);\n            }\n\n            //no session required\n            if (ApiAction.INIT_SESSION.equals(action)) {\n                return processInitSessionRequest(apiRequest);\n            }\n\n            //required session\n            Session session = null;\n            boolean allowNullSession = ApiAction.EXEC.equals(action);\n            String sessionId = apiRequest.getSessionId();\n            if (StringUtils.isBlank(sessionId)) {","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/shell/term/impl/http/api/HttpApiHandler.java#L103-L139","documentation":"Thrown by HttpApiHandler.processRequest when the 'action' field in the parsed ApiRequest is blank. Every HTTP API request must specify an action telling Arthas what operation to perform (e.g. exec, init_session, pull_results).","triggerScenarios":"The JSON body is valid but does not include an 'action' field, or the field is present but empty/null.","commonSituations":"Client constructs the request object programmatically and forgets to set the action field. JSON uses a different key name (e.g. 'type' instead of 'action').","solutions":["Include a non-empty 'action' field matching one of: EXEC, ASYNC_EXEC, INTERRUPT_JOB, PULL_RESULTS, INIT_SESSION, JOIN_SESSION, CLOSE_SESSION, SESSION_INFO.","Double-check the JSON key is exactly 'action' (case-sensitive)."],"exampleFix":"// before\n{\"command\": \"version\"}\n// -> 'action' is required\n\n// after\n{\"action\": \"exec\", \"command\": \"version\"}","handlingStrategy":"validation","validationCode":"// Client-side: verify action is set\nif (apiRequest.getAction() == null || apiRequest.getAction().trim().isEmpty()) {\n    throw new IllegalArgumentException(\"'action' is required\");\n}","typeGuard":"boolean hasValidAction(ApiRequest req) {\n    String a = req.getAction();\n    return a != null && !a.trim().isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Always set the 'action' field when constructing API requests.","Use the exact key name 'action' (case-sensitive)."],"tags":["http-api","request-validation","action"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}