{"record":{"id":"cd4c888633265097","repo":"ruvnet/ruflo","slug":"json-stringify-response-error","errorCode":null,"errorMessage":"JSON.stringify(response.error)","messagePattern":"JSON\\.stringify\\(response\\.error\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ruflo/src/ruvocal/src/lib/APIClient.ts","lineNumber":138,"sourceCode":"\t\tmodels: {\n\t\t\t...endpoint(fetcher, `${baseUrl}/models`),\n\t\t\told: endpoint(fetcher, `${baseUrl}/models/old`),\n\t\t\trefresh: endpoint(fetcher, `${baseUrl}/models/refresh`),\n\t\t},\n\t\t\"public-config\": endpoint(fetcher, `${baseUrl}/public-config`),\n\t\t\"feature-flags\": endpoint(fetcher, `${baseUrl}/feature-flags`),\n\t\tdebug: {\n\t\t\tconfig: endpoint(fetcher, `${baseUrl}/debug/config`),\n\t\t\trefresh: endpoint(fetcher, `${baseUrl}/debug/refresh`),\n\t\t},\n\t\texport: endpoint(fetcher, `${baseUrl}/export`),\n\t};\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function handleResponse(response: ApiResponse<any>): any {\n\tif (response.error) {\n\t\tthrow new Error(JSON.stringify(response.error));\n\t}\n\n\tif (response.data === null) {\n\t\treturn null;\n\t}\n\n\treturn superjson.parse(\n\t\ttypeof response.data === \"string\" ? response.data : JSON.stringify(response.data)\n\t);\n}\n","sourceCodeStart":120,"sourceCodeEnd":149,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/ruflo/src/ruvocal/src/lib/APIClient.ts#L120-L149","documentation":"task_cancel mirrors task_status: it attempts cancellation through the swarm orchestrator and, on any orchestrator failure, falls back to the local taskStore Map. If the task ID is absent from that Map, the simple implementation throws 'Task not found: <id>' before any cancellation logic runs. Note the orchestrator branch may have already logged its own failure — the not-found error can therefore mask an orchestrator connectivity problem rather than a genuinely missing task.","triggerScenarios":"Cancelling a task created before the last server restart; the orchestrator threw (console shows 'Failed to cancel task via orchestrator:') and the local store has no such task; cancelling an ID from another swarm's namespace; already-completed tasks are fine (they return cancelled:false), but unknown IDs throw.","commonSituations":"Cleanup scripts that try to cancel 'all tasks' after a restart without checking what still exists; race where the task finished and was pruned before the cancel arrived; misconfigured orchestrator making every call fall through to the empty local store.","solutions":["Verify the task exists first via task_status or task list; treat 'not found' after a restart as already-gone rather than an error condition","Look for 'Failed to cancel task via orchestrator:' in server logs — if present, fix the orchestrator connection instead of chasing the task ID","Re-create and then cancel if you genuinely need a cancel record for audit purposes","Wrap cancel in a tolerant handler that treats this specific message as a no-op success"],"exampleFix":"// before\nawait client.callTool('task_cancel', { taskId }); // throws [1134] after server restart\n\n// after\ntry {\n  await client.callTool('task_cancel', { taskId, reason: 'superseded' });\n} catch (e) {\n  if (!(e instanceof Error) || !e.message.includes('Task not found')) throw e;\n  // task store was reset by a restart; nothing to cancel\n}","handlingStrategy":"fallback","validationCode":"try {\n  await client.callTool('task_status', { taskId });\n} catch {\n  // task unknown — treat cancel as already-satisfied\n}\n// only call task_cancel when the status call succeeded","typeGuard":null,"tryCatchPattern":"try {\n  const r = await client.callTool('task_cancel', { taskId, reason });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Task not found')) {\n    return { taskId, cancelled: true, note: 'task already gone (restart or pruned)' };\n  }\n  throw e;\n}","preventionTips":["Treat 'Task not found' during cancel as success — the goal (task not running) is achieved","Check server logs for orchestrator fallback before assuming the ID is wrong","Cancel tasks in the same process that created them"],"tags":["mcp","task","not-found","cancel","orchestrator"],"backgroundTag":"task-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}