{"record":{"id":"b48b1679acaa58f8","repo":"alibaba/arthas","slug":"vmtool-interruptthread-id-threadid","errorCode":null,"errorMessage":"vmtool interruptThread 需要指定线程 ID (threadId)","messagePattern":"vmtool interruptThread 需要指定线程 ID \\(threadId\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/mcp/tool/function/jvm300/VMToolTool.java","lineNumber":82,"sourceCode":"        }\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) {\n                cmd.append(\" -t \").append(threadId);\n            } else {\n                throw new IllegalArgumentException(\"vmtool interruptThread 需要指定线程 ID (threadId)\");\n            }\n        }\n\n        return executeSync(toolContext, cmd.toString());\n    }\n\n\n}\n","sourceCodeStart":64,"sourceCodeEnd":91,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/mcp/tool/function/jvm300/VMToolTool.java#L64-L91","documentation":"For the interruptThread action, a valid positive threadId is required to identify which thread to interrupt. A null or non-positive threadId (<=0) is rejected because thread IDs are always positive in the JVM.","triggerScenarios":"Calling vmtool with action=interruptThread while omitting threadId, passing null, or passing a value <= 0.","commonSituations":"User forgets to look up the thread ID first; passes threadId=0; MCP client omits the field; user confuses thread name with numeric ID.","solutions":["Use the thread command or tool first to find the target thread's numeric ID.","Pass a strictly positive threadId value.","Ensure the thread still exists (it may have already terminated)."],"exampleFix":"// before\nvmtool(action=\"interruptThread\")\n// after\n// first run: thread  (to list threads and find nid/tid)\nvmtool(action=\"interruptThread\", threadId=42)","handlingStrategy":"validation","validationCode":"// Before calling vmtool interruptThread, validate threadId\nif (\"interruptThread\".equals(action) && (threadId == null || threadId <= 0)) {\n    throw new IllegalArgumentException(\"A positive threadId is required for interruptThread\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    String result = vmtool(action, ..., threadId, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"threadId\")) {\n        // threadId was missing or non-positive\n    }\n}","preventionTips":["Look up the thread ID via the thread command before calling interruptThread.","Ensure threadId is a positive long value.","Handle the case where the thread may have already terminated."],"tags":["vmtool","required-param","thread","validation","arthas-mcp"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}