{"record":{"id":"82ba25edd577174f","repo":"alibaba/arthas","slug":"prompt-with-name-not-found","errorCode":null,"errorMessage":"Prompt with name '{}' not found","messagePattern":"Prompt with name '(.+?)' not found","errorType":"validation","errorClass":"McpError","httpStatus":null,"severity":"error","filePath":"arthas-mcp-server/src/main/java/com/taobao/arthas/mcp/server/protocol/server/McpStatelessNettyServer.java","lineNumber":413,"sourceCode":"\n\tpublic CompletableFuture<Void> removePrompt(String promptName) {\n\t\tif (promptName == null || promptName.isEmpty()) {\n\t\t\tCompletableFuture<Void> future = new CompletableFuture<>();\n\t\t\tfuture.completeExceptionally(new McpError(\"Prompt name must not be null or empty\"));\n\t\t\treturn future;\n\t\t}\n\t\tif (this.serverCapabilities.getPrompts() == null) {\n\t\t\tCompletableFuture<Void> future = new CompletableFuture<>();\n\t\t\tfuture.completeExceptionally(new McpError(\"Server must be configured with prompt capabilities\"));\n\t\t\treturn future;\n\t\t}\n\n\t\treturn CompletableFuture\n\t\t\t\t.runAsync(() -> {\n\t\t\t\t\tMcpStatelessServerFeatures.PromptSpecification removed =\n\t\t\t\t\t\t\tthis.prompts.remove(promptName);\n\t\t\t\t\tif (removed == null) {\n\t\t\t\t\t\tthrow new CompletionException(new McpError(\"Prompt with name '\" + promptName + \"' not found\"));\n\t\t\t\t\t}\n\t\t\t\t\tlogger.debug(\"Removed prompt handler: {}\", promptName);\n\t\t\t\t})\n\t\t\t\t.exceptionally(ex -> {\n\t\t\t\t\tThrowable cause = (ex instanceof CompletionException) ? ex.getCause() : ex;\n\t\t\t\t\tlogger.error(\"Error while removing prompt '{}'\", promptName, cause);\n\t\t\t\t\tthrow new CompletionException(cause);\n\t\t\t\t});\n\t}\n\n\n\tprivate McpStatelessRequestHandler<McpSchema.ListPromptsResult> promptsListRequestHandler() {\n\t\treturn (exchange, commandContext, params) -> {\n\t\t\tList<McpSchema.Prompt> promptList = new ArrayList<>();\n\t\t\tfor (McpStatelessServerFeatures.PromptSpecification promptSpec : this.prompts.values()) {\n\t\t\t\tpromptList.add(promptSpec.getPrompt());\n\t\t\t}\n\t\t\treturn CompletableFuture.completedFuture(new McpSchema.ListPromptsResult(promptList, null));","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/arthas-mcp-server/src/main/java/com/taobao/arthas/mcp/server/protocol/server/McpStatelessNettyServer.java#L395-L431","documentation":"Thrown by McpStatelessNettyServer.removePrompt() when dynamically unregistering a prompt name not present in the stateless server's prompts map. The async removal returns null and fails the returned CompletableFuture with this McpError wrapped in CompletionException.","triggerScenarios":"Calling removePrompt(name) for a name never added, already removed, or misspelled on a stateless server.","commonSituations":"Double teardown; cleanup of a prompt that never registered; name mismatch; wrong server instance.","solutions":["Track registered prompt names and remove only those present.","Make teardown idempotent with exceptionally(ex -> null).","Reuse the exact name string from registration.","Verify you operate on the McpStatelessNettyServer that owns the prompt."],"exampleFix":"// before\nstatelessServer.removePrompt(name).join(); // throws if absent\n\n// after\nstatelessServer.removePrompt(name)\n    .exceptionally(ex -> null)\n    .join(); // idempotent cleanup","handlingStrategy":"validation","validationCode":"Set<String> addedPrompts = ConcurrentHashMap.newKeySet();\n// on add: addedPrompts.add(name);\nif (addedPrompts.remove(promptName)) {\n    statelessServer.removePrompt(promptName).join();\n}","typeGuard":null,"tryCatchPattern":"statelessServer.removePrompt(promptName)\n    .exceptionally(ex -> {\n        Throwable c = ex instanceof CompletionException ? ex.getCause() : ex;\n        if (c instanceof McpError me && me.getMessage().contains(\"not found\")) return null;\n        throw new CompletionException(c);\n    })\n    .join();","preventionTips":["Track registered prompt names locally.","Make teardown idempotent.","Reuse the exact registered name."],"tags":["mcp","prompt","dynamic-registration","stateless-server","java"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}