{"record":{"id":"e412f2e4be35011d","repo":"Mintplex-Labs/anything-llm","slug":"res-statustext","errorCode":null,"errorMessage":"res.statusText","messagePattern":"res\\.statusText","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/models/embed.js","lineNumber":48,"sourceCode":"    return await fetch(`${API_BASE}/embed/update/${embedId}`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify(data),\n    })\n      .then((res) => res.json())\n      .catch((e) => {\n        console.error(e);\n        return { success: false, error: e.message };\n      });\n  },\n  deleteEmbed: async (embedId) => {\n    return await fetch(`${API_BASE}/embed/${embedId}`, {\n      method: \"DELETE\",\n      headers: baseHeaders(),\n    })\n      .then((res) => {\n        if (res.ok) return { success: true, error: null };\n        throw new Error(res.statusText);\n      })\n      .catch((e) => {\n        console.error(e);\n        return { success: true, error: e.message };\n      });\n  },\n  chats: async (offset = 0) => {\n    return await fetch(`${API_BASE}/embed/chats`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify({ offset }),\n    })\n      .then((res) => res.json())\n      .catch((e) => {\n        console.error(e);\n        return [];\n      });\n  },","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/frontend/src/models/embed.js#L30-L66","documentation":"Thrown by deleteEmbed in the AnythingLLM frontend when DELETE /api/embed/:embedId responds with a non-2xx status; the message is the HTTP status text ('Not Found', 'Unauthorized', ...). Critically, the .catch returns { success: true, error: e.message } — the success:true is a bug: a failed deletion is reported as successful to any caller that only checks the success flag.","triggerScenarios":"Deleting an embed whose UUID no longer exists (404 → 'Not Found'); passing a malformed embedId; calling with an expired or missing auth token (401 'Unauthorized'); an account without permission for that embed (403). In every case the throw happens on !res.ok and the catch then (wrongly) marks it successful.","commonSituations":"Embed already deleted from another tab or by another admin, leaving a stale list entry; workspace removed which cascaded to its embeds; session token expired after a long idle period before the delete was clicked.","solutions":["Do not trust the `success` flag alone — also check the `error` field, which is populated even when success is true.","Refresh the embed list before deleting so the embedId points at an embed that still exists.","If the status is 401/403, re-login or fix permissions, then retry the delete.","Fix the bug in the catch block: return { success: false, ... } so the flag matches reality."],"exampleFix":"// before (frontend/src/models/embed.js)\n.catch((e) => {\n  console.error(e);\n  return { success: true, error: e.message }; // failed delete reported as success\n});\n\n// after\n.catch((e) => {\n  console.error(e);\n  return { success: false, error: e.message }; // flag now matches the outcome\n});","handlingStrategy":"try-catch","validationCode":"// run before deleteEmbed\nif (!embedId || !/^[0-9a-f-]{36}$/i.test(embedId)) {\n  throw new Error('Invalid embed id');\n}","typeGuard":"/** @param {any} r @returns {r is {success: boolean, error: string|null}} */\nfunction isEmbedResult(r) {\n  return typeof r === 'object' && r !== null && typeof r.success === 'boolean';\n}\n// NOTE: until the success:true-in-catch bug is fixed, check `error` too:\nfunction embedDeleted(r) { return isEmbedResult(r) && r.success === true && !r.error; }","tryCatchPattern":"const result = await Embed.deleteEmbed(embedId);\nif (!embedDeleted(result)) {\n  // result.error holds the statusText ('Not Found', 'Unauthorized')\n  showUserError('Could not delete embed', result.error);\n  return false;\n}","preventionTips":["Until the catch bug is fixed, never branch on `success` alone — also check the `error` field.","Refresh the embed list before deleting to avoid 404s on stale ids.","Wrap embed-management flows so a failed delete keeps the row visible instead of optimistically removing it."],"tags":["anythingllm","embed","http-delete","silent-failure","error-handling-bug"],"backgroundTag":"http-request-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}