{"record":{"id":"4cdf23e56d1a7f04","repo":"spring-projects/spring-ai","slug":"error-invoking-progress-method-this-method-getna","errorCode":null,"errorMessage":"Error invoking progress method: {this.method.getName()}","messagePattern":"Error invoking progress method: (.+?)","errorType":"exception","errorClass":"McpProgressMethodException","httpStatus":null,"severity":"error","filePath":"mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/progress/AsyncMcpProgressMethodCallback.java","lineNumber":109,"sourceCode":"\t\t\ttry {\n\t\t\t\t// Build arguments for the method call\n\t\t\t\tObject[] args = this.buildArgs(this.method, null, notification);\n\n\t\t\t\t// Invoke the method\n\t\t\t\tthis.method.setAccessible(true);\n\t\t\t\tObject result = this.method.invoke(this.bean, args);\n\n\t\t\t\t// Handle return type\n\t\t\t\tif (result instanceof Mono) {\n\t\t\t\t\treturn (Mono<?>) result;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// void return type\n\t\t\t\t\treturn Mono.empty();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new McpProgressMethodException(\"Error invoking progress method: \" + this.method.getName(), e);\n\t\t\t}\n\t\t}).flatMap(mono -> mono.then());\n\t}\n\n\t/**\n\t * Create a new builder.\n\t * @return A new builder instance\n\t */\n\tpublic static Builder builder() {\n\t\treturn new Builder();\n\t}\n\n\t/**\n\t * Builder for creating AsyncMcpProgressMethodCallback instances.\n\t * <p>\n\t * This builder provides a fluent API for constructing AsyncMcpProgressMethodCallback\n\t * instances with the required parameters.\n\t */","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/mcp/mcp-annotations/src/main/java/org/springframework/ai/mcp/annotation/method/progress/AsyncMcpProgressMethodCallback.java#L91-L127","documentation":"When the annotated progress method itself throws while being reflectively invoked by AsyncMcpProgressMethodCallback.apply, the exception is wrapped in an McpProgressMethodException with this message naming the failing method. The original cause is attached, so it indicates a runtime failure inside user handler code, not a signature problem.","triggerScenarios":"The progress handler method (void or Mono-producing path) throws an exception during synchronous part of its execution when a ProgressNotification is applied via the callback.","commonSituations":"NPE inside the handler from unvalidated notification fields; illegalStateException from accessing closed resources; any user-code bug surfaced during progress delivery from a client (e.g. during long-running tool execution).","solutions":["Inspect the cause chain of the McpProgressMethodException and fix the underlying exception in the handler method.","Add defensive null/argument checks inside the progress handler before using notification values.","Wrap risky handler logic in try-catch or onErrorResume to degrade gracefully instead of failing the notification."],"exampleFix":"// before\npublic void onProgress(Double p, String token, String msg) {\n    tracker.update(token, p); // NPE if tracker not initialized\n}\n// after\npublic void onProgress(Double p, String token, String msg) {\n    if (tracker != null) tracker.update(token, p);\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    callback.accept(notification);\n} catch (McpProgressMethodException e) {\n    log.error(\"Progress handler {} failed: {}\", e.getMessage(), e.getCause(), e);\n    // do not rethrow if progress failure must not abort the main operation\n}","preventionTips":["Make progress handlers defensive: null-check notification fields before use.","Keep heavy or failing logic out of progress handlers; log and swallow non-critical failures.","Add onErrorResume in reactive handler chains so Mono errors are handled locally."],"tags":["mcp","progress-notification","reflection-invocation","wrapped-exception"],"backgroundTag":"handler-invocation-failed","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}