{"record":{"id":"f258804d6a12e976","repo":"alibaba/arthas","slug":"vmtool-normalizedaction-classname","errorCode":null,"errorMessage":"vmtool ${normalizedAction} 需要指定类名 (className)","messagePattern":"vmtool (.+?) 需要指定类名 \\(className\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/mcp/tool/function/jvm300/VMToolTool.java","lineNumber":61,"sourceCode":"            ToolContext toolContext\n    ) {\n        StringBuilder cmd = buildCommand(\"vmtool\");\n\n        if (action == null || action.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"vmtool: action 参数不能为空\");\n        }\n        String normalizedAction = action.trim();\n        cmd.append(\" --action \").append(normalizedAction);\n\n        if (classLoaderHash != null && !classLoaderHash.trim().isEmpty()) {\n            addParameter(cmd, \"-c\", classLoaderHash);\n        } else if (classLoaderClass != null && !classLoaderClass.trim().isEmpty()) {\n            addParameter(cmd, \"--classLoaderClass\", classLoaderClass);\n        }\n\n        if (ACTION_GET_INSTANCES.equals(normalizedAction) || ACTION_REFERENCE_ANALYZE.equals(normalizedAction)) {\n            if (className == null || className.trim().isEmpty()) {\n                throw new IllegalArgumentException(\"vmtool \" + normalizedAction + \" 需要指定类名 (className)\");\n            }\n            addParameter(cmd, \"--className\", className);\n        }\n\n        if (ACTION_GET_INSTANCES.equals(normalizedAction)) {\n            if (limit != null) {\n                cmd.append(\" --limit \").append(limit);\n            }\n            if (expandLevel != null && expandLevel > 0) {\n                cmd.append(\" -x \").append(expandLevel);\n            }\n            if (express != null && !express.trim().isEmpty()) {\n                addParameter(cmd, \"--express\", express);\n            }\n        }\n\n        if (ACTION_INTERRUPT_THREAD.equals(normalizedAction)) {\n            if (threadId != null && threadId > 0) {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/mcp/tool/function/jvm300/VMToolTool.java#L43-L79","documentation":"For the getInstances and referenceAnalyze actions, a fully-qualified className is mandatory because Arthas needs to know which class to search for live instances or analyze object references. Without it the underlying vmtool --action command would be meaningless.","triggerScenarios":"Calling vmtool with action=getInstances or action=referenceAnalyze while omitting className or passing a blank value. The check at line 59-62 runs after classLoaderHash/classLoaderClass processing.","commonSituations":"User forgets className assuming the tool infers it from context; passes an empty string; MCP client drops the field.","solutions":["Provide className as a fully-qualified Java class name (e.g., com.example.MyService or java.lang.String).","Double-check that the action you chose (getInstances/referenceAnalyze) actually requires className.","Ensure className is not whitespace-only."],"exampleFix":"// before\nvmtool(action=\"getInstances\")\n// after\nvmtool(action=\"getInstances\", className=\"java.util.HashMap\")","handlingStrategy":"validation","validationCode":"// Before calling vmtool with getInstances/referenceAnalyze, validate className\nif ((\"getInstances\".equals(action) || \"referenceAnalyze\".equals(action))\n        && (className == null || className.trim().isEmpty())) {\n    throw new IllegalArgumentException(\"className is required for \" + action);\n}","typeGuard":null,"tryCatchPattern":"try {\n    String result = vmtool(action, ..., className, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"className\")) {\n        // className was missing for getInstances/referenceAnalyze\n    }\n}","preventionTips":["Always pair getInstances/referenceAnalyze with a fully-qualified className.","Validate that className is non-empty before calling the tool.","Use the package-qualified class name, not a simple name."],"tags":["vmtool","required-param","validation","arthas-mcp"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}