{"record":{"id":"8a6838674d64e46a","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-remove-pfp","errorCode":null,"errorMessage":"Failed to remove pfp.","messagePattern":"Failed to remove pfp\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/models/system.js","lineNumber":510,"sourceCode":"      headers: baseHeaders(),\n    })\n      .then((res) => {\n        if (res.ok && res.status !== 204) return res.blob();\n        throw new Error(\"Failed to fetch pfp.\");\n      })\n      .then((blob) => (blob ? URL.createObjectURL(blob) : null))\n      .catch(() => {\n        return null;\n      });\n  },\n  removePfp: async function () {\n    return await fetch(`${API_BASE}/system/remove-pfp`, {\n      method: \"DELETE\",\n      headers: baseHeaders(),\n    })\n      .then((res) => {\n        if (res.ok) return { success: true, error: null };\n        throw new Error(\"Failed to remove pfp.\");\n      })\n      .catch((e) => {\n        console.log(e);\n        return { success: false, error: e.message };\n      });\n  },\n\n  isDefaultLogo: async function () {\n    return await fetch(`${API_BASE}/system/is-default-logo`, {\n      method: \"GET\",\n      cache: \"no-cache\",\n    })\n      .then((res) => {\n        if (!res.ok) throw new Error(\"Failed to get is default logo!\");\n        return res.json();\n      })\n      .then((res) => res?.isDefaultLogo)\n      .catch((e) => {","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/system.js#L492-L528","documentation":"Thrown by System.removePfp when the DELETE to /api/system/remove-pfp returns non-2xx. baseHeaders() is sent (auth required). On res.ok it returns {success:true, error:null}; otherwise it throws and the .catch() returns {success:false, error:e.message}.","triggerScenarios":"Calling removePfp() when the user has no pfp to remove (404/409), when the storage delete fails server-side (500), or when the auth token is rejected/expired (401/403).","commonSituations":"User already removed their pfp and clicks remove again; filesystem is read-only so the server cannot delete the file; token expired before the action completed.","solutions":["Confirm localStorage AUTH_TOKEN is still valid before the delete.","Check server logs for the underlying filesystem error on delete.","Tolerate a 404 on remove (the pfp is already gone) at the UI layer.","Verify write/delete permissions on the pfp storage directory."],"exampleFix":"// before\nconst res = await System.removePfp();\nif (!res.success) alert(res.error);\n\n// after (treat already-removed as success)\nconst res = await System.removePfp();\nif (!res.success && !/not found|404/i.test(res.error)) alert(res.error);","handlingStrategy":"validation","validationCode":"function canMutatePfp() {\n  return !!window.localStorage.getItem(\"anythingllm_authToken\");\n}","typeGuard":"/** @param {any} r @returns {r is {success:boolean, error:string|null}} */\nfunction isMutationResult(r) { return r != null && typeof r.success === \"boolean\"; }","tryCatchPattern":"if (!canMutatePfp()) { routeToLogin(); return; }\nconst res = await System.removePfp();\nif (!isMutationResult(res) || !res.success) {\n  if (!/404|not found/i.test(res.error)) showError(res.error);\n}","preventionTips":["Tolerate a 404 (pfp already removed) as success.","Confirm write/delete perms on the pfp storage dir.","Refresh the UI avatar state after success."],"tags":["network","profile","delete","auth"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}