{"record":{"id":"43933f912b496593","repo":"bytedance/deer-flow","slug":"request-failed-43933f","errorCode":null,"errorMessage":"Request failed.","messagePattern":"Request failed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/core/threads/hooks.ts","lineNumber":2419,"sourceCode":"      }\n      return submitPreparedReplay({\n        threadId,\n        prepare: async () => {\n          const response = await fetch(\n            `${getBackendBaseURL()}/api/threads/${encodeURIComponent(\n              threadId,\n            )}/runs/regenerate/prepare`,\n            {\n              method: \"POST\",\n              headers: {\n                \"Content-Type\": \"application/json\",\n              },\n              credentials: \"include\",\n              body: JSON.stringify({ message_id: messageId }),\n            },\n          );\n          if (!response.ok) {\n            throw new Error(await readResponseErrorMessage(response));\n          }\n          return (await response.json()) as RegeneratePrepareResponse;\n        },\n        getSupersededMessageIds: () => supersededMessageIds,\n      });\n    },\n    [submitPreparedReplay],\n  );\n\n  const editAndRegenerateMessage = useCallback(\n    async (\n      threadId: string,\n      humanMessageId: string,\n      replacementText: string,\n    ) => {\n      if (!humanMessageId) {\n        return false;\n      }","sourceCodeStart":2401,"sourceCodeEnd":2437,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/frontend/src/core/threads/hooks.ts#L2401-L2437","documentation":"Generic wrapper for a failed POST to /api/threads/{threadId}/runs/regenerate/prepare in the regenerate flow. When the response is not ok, readResponseErrorMessage extracts the body's error detail; the literal 'Request failed.' is that helper's default when the body carries no parseable detail.","triggerScenarios":"Regenerating a message whose thread/run no longer exists on the server (404), a gateway 500 while preparing the replay state, auth/cookie expiry returning 401/403, or an nginx route miss returning a non-JSON error page so the detail cannot be extracted.","commonSituations":"Session cookie expired while the tab sat open, gateway restarted and lost in-memory run state, regenerating from an old thread after the server data was pruned.","solutions":["Check the Network tab for the regenerate/prepare request: the HTTP status and body pinpoint the cause (404 gone, 401 auth, 500 server).","If 401/403, re-authenticate and retry the regeneration from the UI.","If 404/410, the run state is gone server-side — reload the thread; regenerate may be unavailable for that message.","If 500, inspect gateway logs at the timestamp of the request for the prepare-handler traceback."],"exampleFix":"// before: opaque error\nthrow new Error(await readResponseErrorMessage(response));\n\n// after: include status for diagnosability\nconst detail = await readResponseErrorMessage(response);\nthrow new Error(`Regenerate prepare failed (${response.status}): ${detail}`);","handlingStrategy":"try-catch","validationCode":"// Nothing client-side can fully pre-validate a server prepare step; verify the thread/run still exist first if a cheap read endpoint is available.","typeGuard":null,"tryCatchPattern":"try { await regenerateMessage(threadId, messageId); } catch (e) { if (/Request failed/.test(e.message)) { const status = lastRegenerateStatus(); if (status === 401) { await relogin(); } else { toast('Regeneration unavailable — reload the thread.'); } return; } throw e; }","preventionTips":["Attach response.status to the thrown error so callers can branch on it instead of string matching.","Disable regenerate UI for messages whose run no longer exists (prune markers from the server).","Refresh sessions proactively in long-lived tabs to avoid 401s mid-action."],"tags":["api","regenerate","network","frontend"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}