alibaba/arthas · error · McpError

-32603

-32603

Error message

Task creation failed: {}

What it means

Thrown by ServerTaskToolHandler when a task-aware tool's createTaskHandler().createTask(...) fails with a cause that is not already a McpError. The handler wraps the cause's message into a fresh McpError with ErrorCodes.INTERNAL_ERROR (-32603). If the underlying cause is already a McpError (e.g. capacity limit), it is rethrown unchanged.

Source

Thrown at arthas-mcp-server/src/main/java/com/taobao/arthas/mcp/server/task/ServerTaskToolHandler.java:264

        CreateTaskContext extra = new DefaultCreateTaskContext(
                this.taskStore,
                getTaskMessageQueue(),
                exchange,
                sessionId,
                requestTtl,
                request,
                commandContext,
                this.sessionManager
        );

        Map<String, Object> args = request.getArguments() != null ? request.getArguments() : Collections.emptyMap();

        return taskTool.createTaskHandler().createTask(args, extra)
                .exceptionally(ex -> {
                    Throwable cause = ex instanceof CompletionException ? ex.getCause() : ex;
                    if (!(cause instanceof McpError)) {
                        throw new CompletionException(new McpError(
                                new McpSchema.JSONRPCResponse.JSONRPCError(
                                        McpSchema.ErrorCodes.INTERNAL_ERROR,
                                        "Task creation failed: " + cause.getMessage(),
                                        null
                                )
                        ));
                    }
                    throw new CompletionException(cause);
                });
    }

    /** Handles automatic task polling for a task-aware tool call without task metadata. */
    private CompletableFuture<McpSchema.CallToolResult> handleAutomaticTaskPolling(
            McpNettyServerExchange exchange,
            ArthasCommandContext commandContext,
            McpSchema.CallToolRequest request,
            TaskAwareToolSpecification taskTool) {

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Inspect the wrapped cause (getCause() of the CompletionException) to find the real failure and fix it at the source.
  2. Make the createTask handler robust: validate inputs and return a clean McpError for expected failure modes instead of letting raw exceptions escape.
  3. Add logging inside the handler to capture the original exception before wrapping.
  4. Fix the root cause (null checks, retries for transient downstream errors) rather than only handling the wrapped error.

Example fix

// before
public CompletableFuture<McpSchema.Result> createTask(Map<String,Object> args, TaskExtra extra) {
    String path = (String) args.get("path"); // NPE if missing -> wrapped
    return run(path);
}

// after
public CompletableFuture<McpSchema.Result> createTask(Map<String,Object> args, TaskExtra extra) {
    String path = (String) args.get("path");
    if (path == null) {
        return failedFuture(McpError.builder(ErrorCodes.INVALID_PARAMS)
            .message("'path' is required").build());
    }
    return run(path);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate handler inputs before delegating to createTask
public CompletableFuture<McpSchema.Result> createTask(Map<String,Object> args, TaskExtra extra) {
    if (args.get("path") == null) {
        return failedFuture(McpError.builder(McpSchema.ErrorCodes.INVALID_PARAMS)
            .message("'path' is required").build());
    }
    return delegate.createTask(args, extra);
}

Try / catch

taskTool.createTaskHandler().createTask(args, extra)
    .exceptionally(ex -> {
        Throwable cause = ex instanceof CompletionException ? ex.getCause() : ex;
        if (cause instanceof McpError me) throw new CompletionException(me);
        logger.error("Task creation failed", cause);
        throw new CompletionException(new McpError(
            new McpSchema.JSONRPCResponse.JSONRPCError(
                McpSchema.ErrorCodes.INTERNAL_ERROR,
                "Task creation failed: " + cause.getMessage(), null)));
    }).join();

Prevention

When it happens

Trigger: The task handler throws any RuntimeException/Error that is not a McpError — e.g. NPE, IOException, deserialization failure, argument error, or a downstream service exception; resource exhaustion in the handler.

Common situations: Handler bug (NPE) in createTask logic; invalid arguments causing a library exception; external service outage surfacing as a generic exception; serialization issues with task arguments.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/658a5e9d854e2dba. Report an issue: GitHub.