{"record":{"id":"7f76b9d9fefeada2","repo":"Significant-Gravitas/AutoGPT","slug":"unexpected-response-from-server","errorCode":null,"errorMessage":"Unexpected response from server","messagePattern":"Unexpected response from server","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"autogpt_platform/frontend/src/components/organisms/NeedsAttentionList/useNeedsAttentionList.ts","lineNumber":54,"sourceCode":"        [\n          {\n            node_exec_id: review.node_exec_id,\n            approved,\n            // No message: this surface has no field to write one in, and a\n            // canned English string would reach the agent's context and the\n            // audit trail as if the user had typed it.\n            auto_approve_future: false,\n          },\n        ],\n        [review.graph_exec_id],\n      );\n\n      // The mutation resolves rather than throws on a non-200, and a 200 can\n      // still carry failed_count > 0 (review already processed, node\n      // execution gone). Reporting either as success would leave the row\n      // reappearing on the next refetch with nothing explaining why.\n      if (res.status !== 200) {\n        throw new Error(\"Unexpected response from server\");\n      }\n      if (res.data.failed_count > 0) {\n        throw new Error(res.data.error || \"The review could not be processed.\");\n      }\n\n      toast({ title: approved ? \"Approved\" : \"Declined\" });\n    } catch (error) {\n      toast({\n        title: `Failed to ${verb} review`,\n        description:\n          error instanceof Error ? error.message : \"An error occurred\",\n        variant: \"destructive\",\n      });\n    } finally {\n      setPending(review.node_exec_id, false);\n    }\n  }\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/frontend/src/components/organisms/NeedsAttentionList/useNeedsAttentionList.ts#L36-L72","documentation":"Thrown by the NeedsAttentionList approve/decline handler when the execution-review mutation resolves with a status other than 200. Per the code comment, the generated mutation resolves (doesn't throw) on non-2xx, so this explicit guard converts silent failures into user-visible errors — otherwise the row would just reappear on refetch with no explanation.","triggerScenarios":"POST of the agent-review batch returning 401 (expired session), 404 (graph execution deleted), 422, or 5xx while the user clicks Approve/Decline on an attention-list row.","commonSituations":"Session expiry on a long-idle dashboard; the execution or its review artifacts already cleaned up by retention; backend restart between list load and action.","solutions":["Check the mutation request in DevTools for the real status/body — the thrown message intentionally includes no detail, the network tab has it.","401 → sign in again; the pending row will still be there after re-auth.","Refresh the list: if the row vanished, the review was already processed or the execution was pruned — nothing left to act on.","5xx → retry once backend health is restored; the mutation is idempotent from the UI side."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isUnexpectedServerResponse(err: unknown): boolean {\n  return err instanceof Error && err.message === \"Unexpected response from server\";\n}","tryCatchPattern":"try {\n  await reviewMutation(...);\n} catch (error) {\n  if (isUnexpectedServerResponse(error)) {\n    // check network tab for the real status; refresh list before retry\n    await queryClient.invalidateQueries({ queryKey: [\"needsAttention\"] });\n  }\n}","preventionTips":["Never assume generated mutations throw on non-2xx — add explicit status checks like this one.","Invalidate the attention list after any failure so stale rows can't be re-acted on.","Include the status code in the thrown message when extending this code — it currently forces a network-tab trip."],"tags":["reviews","needs-attention","mutation","http-status","frontend"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}