{"record":{"id":"2746967f70f7de78","repo":"alibaba/arthas","slug":"actionarg-is-required-when-action-execute","errorCode":null,"errorMessage":"actionArg is required when action=execute","messagePattern":"actionArg is required when action=execute","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/mcp/tool/function/monitor200/ProfilerTool.java","lineNumber":161,"sourceCode":"            String timeout,\n\n            @ToolParam(description = \"持续采样秒数 (--duration)。注意：到时自动 stop 在后台执行，stop 的结果不会回传到当前命令输出。\", required = false)\n            Long duration,\n\n            @ToolParam(description = \"启用的特性集合 (--features)\", required = false)\n            String features,\n\n            @ToolParam(description = \"采样信号 (--signal)\", required = false)\n            String signal,\n\n            @ToolParam(description = \"时间戳时钟源 (--clock)，可选 monotonic 或 tsc\", required = false)\n            String clock,\n\n            ToolContext toolContext\n    ) {\n        String normalizedAction = normalizeAction(action);\n        if (\"execute\".equals(normalizedAction) && (actionArg == null || actionArg.trim().isEmpty())) {\n            throw new IllegalArgumentException(\"actionArg is required when action=execute\");\n        }\n\n        StringBuilder cmd = buildCommand(\"profiler\");\n        cmd.append(\" \").append(normalizedAction);\n\n        if (actionArg != null && !actionArg.trim().isEmpty()) {\n            addParameter(cmd, actionArg);\n        }\n\n        // profiler options\n        addOption(cmd, \"--event\", event);\n        addOption(cmd, \"--alloc\", alloc);\n        addFlag(cmd, \"--live\", live);\n        addOption(cmd, \"--lock\", lock);\n        addOption(cmd, \"--jfrsync\", jfrsync);\n\n        addOption(cmd, \"--file\", file);\n        addOption(cmd, \"--format\", format);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/mcp/tool/function/monitor200/ProfilerTool.java#L143-L179","documentation":"The profiler execute action passes raw arguments directly to the async-profiler agent via actionArg. Because execute bypasses the structured option mapping, actionArg is the sole carrier of the command and must not be empty.","triggerScenarios":"Calling the profiler tool with action=execute but omitting actionArg or passing a blank value. The check at line 160 runs immediately after normalizeAction succeeds.","commonSituations":"User confuses execute with start (which uses structured options, not actionArg); forgets to include the agent arguments string; assumes execute infers defaults.","solutions":["Provide actionArg with valid async-profiler agent arguments, e.g. \"start,event=cpu\" or \"stop,file=/tmp/result.html\".","For common use cases prefer action=start with structured options (event, file, format) instead of action=execute.","Check that actionArg is not whitespace-only."],"exampleFix":"// before\nprofiler(action=\"execute\")\n// after\nprofiler(action=\"execute\", actionArg=\"start,event=cpu\")\n// or simpler: use structured action\nprofiler(action=\"start\", event=\"cpu\")","handlingStrategy":"validation","validationCode":"// Before calling profiler execute, validate actionArg\nif (\"execute\".equalsIgnoreCase(action)\n        && (actionArg == null || actionArg.trim().isEmpty())) {\n    throw new IllegalArgumentException(\"actionArg is required when action=execute\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    String result = profiler(action, actionArg, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"actionArg\")) {\n        // actionArg missing for execute — switch to structured action=start or provide args\n    }\n}","preventionTips":["Prefer structured actions (start, stop) over execute for common profiling scenarios.","If using execute, always include the full async-profiler agent argument string.","Validate actionArg client-side when action is execute."],"tags":["profiler","required-param","async-profiler","validation","arthas-mcp"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}