Mintplex-Labs/anything-llm · warning · Error

Failed to remove pfp.

Error message

Failed to remove pfp.

What it means

Thrown by removePfp in the AnythingLLM frontend when DELETE /api/system/remove-pfp responds non-2xx, with the fixed message 'Failed to remove pfp.' and no status detail. The catch returns { success: false, error }, so the UI can still show what happened.

Solutions

  1. Refresh the user/profile state — if the picture is already gone, nothing needs deleting.
  2. Confirm the session token is valid (re-login if 401).
  3. On self-hosted, check that the storage output folder is writable so the unlink succeeds.
  4. Check the Network tab status code to tell 401/404/500 apart.
Defensive patterns

Strategy: try-catch

Validate before calling

// run before System.removePfp
if (!userFromStorage()?.hasPfp) return; // nothing to remove — skip the request

Try / catch

const { success, error } = await System.removePfp();
if (!success) {
  // 'Failed to remove pfp.' — benign if already removed; refresh profile state
  console.warn(error);
}
await refreshUser(); // always resync UI with server truth

Prevention

When it happens

Trigger: Deleting when no profile picture exists anymore (server rejects the delete); a missing/expired auth token; a filesystem error while unlinking the stored image on the server.

Common situations: Double-clicking the remove button so the second request targets an already-removed file; stale profile UI state after the picture was removed in another tab; read-only storage volume on self-hosted installs.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/8a6838674d64e46a. Report an issue: GitHub.

Appendix: source

Thrown at frontend/src/models/system.js:510

      headers: baseHeaders(),
    })
      .then((res) => {
        if (res.ok && res.status !== 204) return res.blob();
        throw new Error("Failed to fetch pfp.");
      })
      .then((blob) => (blob ? URL.createObjectURL(blob) : null))
      .catch(() => {
        return null;
      });
  },
  removePfp: async function () {
    return await fetch(`${API_BASE}/system/remove-pfp`, {
      method: "DELETE",
      headers: baseHeaders(),
    })
      .then((res) => {
        if (res.ok) return { success: true, error: null };
        throw new Error("Failed to remove pfp.");
      })
      .catch((e) => {
        console.log(e);
        return { success: false, error: e.message };
      });
  },

  isDefaultLogo: async function () {
    return await fetch(`${API_BASE}/system/is-default-logo`, {
      method: "GET",
      cache: "no-cache",
    })
      .then((res) => {
        if (!res.ok) throw new Error("Failed to get is default logo!");
        return res.json();
      })
      .then((res) => res?.isDefaultLogo)
      .catch((e) => {

View on GitHub (pinned to 20f6d3546c)