Skip to content

Commit 47a92dc

Browse files
jirispilkaclaude
andauthored
fix: Log task-not-found as softFail instead of error (#678)
fix: log task-not-found as softFail instead of error Task-not-found and cancel-on-terminal-state are client errors (invalid taskId / illegal transition), not server faults. Logging them as error pollutes Mezmo error alerts. Switch to softFail with statusCode, keep the McpError(InvalidParams) response unchanged. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7bd4199 commit 47a92dc

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/mcp/server.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ export class ActorsMcpServer {
539539
const task = await this.taskStore.getTask(taskId, mcpSessionId);
540540
if (task) return task;
541541

542-
// logging as this may not be just a soft fail but related to issue with the task store
543-
log.error('[GetTaskRequestSchema] Task not found', { taskId, mcpSessionId });
542+
// Client error (invalid/unknown taskId) — softFail to avoid polluting error logs.
543+
log.softFail('[GetTaskRequestSchema] Task not found', { taskId, mcpSessionId, statusCode: 404 });
544544
throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found`);
545545
});
546546

@@ -553,8 +553,8 @@ export class ActorsMcpServer {
553553
log.debug('[GetTaskPayloadRequestSchema] Getting task result', { taskId, mcpSessionId });
554554
const task = await this.taskStore.getTask(taskId, mcpSessionId);
555555
if (!task) {
556-
// logging as this may not be just a soft fail but related to issue with the task store
557-
log.error('[GetTaskPayloadRequestSchema] Task not found', { taskId, mcpSessionId });
556+
// Client error (invalid/unknown taskId) — softFail to avoid polluting error logs.
557+
log.softFail('[GetTaskPayloadRequestSchema] Task not found', { taskId, mcpSessionId, statusCode: 404 });
558558
throw new McpError(
559559
ErrorCode.InvalidParams,
560560
`Task "${taskId}" not found`,
@@ -579,18 +579,20 @@ export class ActorsMcpServer {
579579

580580
const task = await this.taskStore.getTask(taskId, mcpSessionId);
581581
if (!task) {
582-
// logging as this may not be just a soft fail but related to issue with the task store
583-
log.error('[CancelTaskRequestSchema] Task not found', { taskId, mcpSessionId });
582+
// Client error (invalid/unknown taskId) — softFail to avoid polluting error logs.
583+
log.softFail('[CancelTaskRequestSchema] Task not found', { taskId, mcpSessionId, statusCode: 404 });
584584
throw new McpError(
585585
ErrorCode.InvalidParams,
586586
`Task "${taskId}" not found`,
587587
);
588588
}
589589
if (task.status === 'completed' || task.status === 'failed' || task.status === 'cancelled') {
590-
log.error('[CancelTaskRequestSchema] Task already in terminal state', {
590+
// Client error (cancel on terminal task) — softFail to avoid polluting error logs.
591+
log.softFail('[CancelTaskRequestSchema] Task already in terminal state', {
591592
taskId,
592593
mcpSessionId,
593594
status: task.status,
595+
statusCode: 409,
594596
});
595597
throw new McpError(
596598
ErrorCode.InvalidParams,

0 commit comments

Comments
 (0)