Repository navigation
fix(server): return errors for cancelled legacy task results - #1157
Conversation
|
Connected to Huly®: MCP_G-716 |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Record and return cancellation errors server/server.go, server/task_cancel_result_test.go |
Task result handling returns REQUEST_INTERRUPTED for cancellation errors. Tests cover cancellation before and during result waits, repeated requests, late completion, task state, HTTP envelopes, and error classification. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- mark3labs/mcp-go#1156 — The PR changes cancelled task results from successful metadata-only responses to
REQUEST_INTERRUPTEDerrors.
Suggested labels: type: bug, area: sdk
Suggested reviewers: jaormx
Merge Risk: 
Minimal · up to 9110b
-
Cancelled task results return an interruption error rather than a successful metadata-only response. No actionable merge-blocking risk remains in the supplied evidence.
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Title check
-
Explanation
The title "fix(server): return errors for cancelled legacy task results" matches the main change. The raw summary says cancelling a task now stores context.Canceled as its result error, and task-result failures return REQUEST_INTERRUPTED when that error matches. The title is specific and concise, uses a conventional scope prefix, and states the bug fix from the developer's perspective.
Full details: Description check
-
Explanation
The description covers the problem, the fix, and the scope. It explains that cancelled legacy tasks returned a successful metadata-only tasks/result envelope. It states that the fix records context.Canceled in the terminal transition and returns REQUEST_INTERRUPTED (-32800). It notes that ordinary failures keep INTERNAL_ERROR and that SEP-2663 tasks/get is out of scope. It links issue
#1156, marks Bug fix, and includes detailed test and validation notes. The template sections are all present. The Checklist item for documentation is left unchecked with an explanation. The 'Fixes#1156' line follows the template. The MCP Spec Compliance section was removed, which the template marks as optional. The description is complete and specific.
Full details: Out of Scope Changes check
-
Explanation
The changes are limited to the legacy task-result error path and regression tests for cancellation, waiting, repeated retrieval, late completion, HTTP envelopes, and error classification. No changes affect
tasks/get, task lifetime, TTL, capacity, or the Tasks Extension.
-
Full details: Linked Issues check
-
Explanation
Issue
#1156requires cancelled legacytasks/resultrequests to returnREQUEST_INTERRUPTED. The cancellation transition storescontext.Canceled, andhandleTaskResultmaps that error correctly. However, the addedTestTaskResultErrorClassificationexpectsREQUEST_INTERRUPTEDforcontext.DeadlineExceeded. The implementation checks onlyerrors.Is(resultErr, context.Canceled), so that case returnsINTERNAL_ERRORand the added test fails.Resolution
Resolve the
context.DeadlineExceededclassification mismatch. Update the result-error mapping if deadline errors must returnREQUEST_INTERRUPTED, or change the added test if that behavior is not required. The complete added test suite must pass.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Description
Fixes #1156.
Cancelled legacy tasks currently return a successful
tasks/resultenvelope containing only_meta. The cancellation transition closesdonewithout storing an error, and the terminal-state guard then discards the handler's return value.Record
context.Canceledin that same terminal transition and return the existingREQUEST_INTERRUPTEDcode (-32800) during result retrieval. Waiting and repeated readers get the cancellation error; late handler completion cannot replace it. Ordinary failures keepINTERNAL_ERRORand successful results are unchanged.This affects the supported legacy
tasks/resultpath only. It does not change SEP-2663tasks/getor the extension work in #987, nor the execution-lifetime fix in #1054.Type of Change
Checklist
Additional Information
Validated on Linux/WSL with Go 1.26.9; lint used the CI-pinned golangci-lint 2.8.0 with Go 1.25.5.
go test -mod=readonly -race -json -p 2 ./... -count=1 -timeout=600sexhausted its overall transport-package budget while compiling stdio fixtures; rerunninggo test -mod=readonly -race -json -p 2 ./client/transport -count=1 -timeout=1800spassed in 434s. Other packages passed in the first run../serverrace suite rerun with all added cases: passed.cd otel && go test -mod=readonly -race -p 2 ./... -count=1 -timeout=180s: passed.go build -mod=readonly -p 2 ./...,go vet -mod=readonly -p 2 ./...,go generate ./..., andgit diff --check: passed; generated source unchanged.golangci-lint run --timeout=5min root and otel: 0 issues.GOFLAGS=-buildvcs=falsewas inherited by child Go builds because this is a Windows-created worktree tested under WSL. No test or CI settings were changed.The reproducer failed three times on unchanged main. Removing the stored cancellation error or restoring the wrong error classification via Go overlays makes the new assertions fail. Coverage includes cooperative regular-tool cancellation, task-tool cancellation/deadline, the non-terminal result waiting branch, repeated retrieval, late success, ordinary success/failure controls, and a real HTTP result envelope. The HTTP test internally creates/cancels the task; it is not a complete HTTP tools/call end-to-end test.
AI-assisted investigation, implementation and tests; local results were executed and the diff independently reviewed.
Summary by CodeRabbit