Mintplex-Labs/anything-llm · warning · Error
Failed to fetch pfp.
Error message
Failed to fetch pfp.
What it means
Thrown by System.fetchPfp when the GET to /api/system/pfp/{id} returns a non-2xx status OR a 204 (no pfp set). Unlike fetchLogo it DOES send baseHeaders(). The .catch() returns null, so any failure — including the benign 204 — yields null and the UI shows the default avatar.
Source
Thrown at frontend/src/models/system.js:496
const logoURL = URL.createObjectURL(blob);
return { isCustomLogo, logoURL };
}
throw new Error("Failed to fetch logo!");
})
.catch((e) => {
console.log(e);
return { isCustomLogo: false, logoURL: null };
});
},
fetchPfp: async function (id) {
return await fetch(`${API_BASE}/system/pfp/${id}`, {
method: "GET",
cache: "no-cache",
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 };View on GitHub (pinned to 526360e320)
Solutions
- Treat 204 as 'no avatar' rather than an error condition.
- Confirm the id matches an existing user record.
- Verify localStorage AUTH_TOKEN is present since baseHeaders() is sent.
- Cache the null result to avoid repeated failing requests for the same user.
Example fix
// before
if (res.ok && res.status !== 204) return res.blob();
throw new Error("Failed to fetch pfp.");
// after (204 is benign)
if (res.status === 204) return null;
if (!res.ok) throw new Error(`Failed to fetch pfp. (${res.status})`);
return res.blob(); Defensive patterns
Strategy: fallback
Validate before calling
function validUserId(id) {
return (typeof id === "string" || typeof id === "number") && String(id).length > 0;
}
// Also ensure AUTH_TOKEN is set (baseHeaders is sent). Type guard
/** @param {any} r @returns {r is string|null} */
function isObjectUrlOrNull(r) { return r === null || typeof r === "string"; } Try / catch
const url = await System.fetchPfp(id);
if (!isObjectUrlOrNull(url) || !url) { renderDefaultAvatar(); } Prevention
- Treat 204 as 'no avatar' — benign, not an error.
- Cache null results per user id to avoid repeat failing calls.
- Revoke object URLs on unmount.
When it happens
Trigger: Calling fetchPfp(userId) when the user has no profile picture (204), when the id does not correspond to a user (404), or when the auth token is rejected (401/403).
Common situations: A new user who never uploaded a pfp returns 204 every time; a deleted user's id is passed; the token expired before the avatar render.
Related errors
- Error uploading pfp.
- Failed to remove pfp.
- Failed to sync Confluence page content. ${reason}
- Failed to sync GitHub file content. ${reason}
- Failed to sync GitLab file content. ${reason}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/02f4e259c785c1a0.
Report an issue: GitHub.