Mintplex-Labs/anything-llm · error
Internal Server Error
Error message
Internal Server Error
What it means
Catch-all 500 for GET /embeds, the admin listing of embed configurations. EmbedConfig.whereWithWorkspace runs a Prisma join (embed_configs with workspaces); if that query rejects — schema drift after an upgrade, missing columns, unreadable/locked sqlite file — the handler logs the error and returns a bare 500. Auth/role failures never reach this line (they are handled by flexUserRoleValid middleware earlier).
Solutions
- Check server console for the Prisma error printed by console.error(e)
- Restart the server/container so boot-time migrations and Prisma schema sync complete, then reload /embeds
- Confirm the storage directory and anythingllm.db are writable and owned by the server user
- If schema drift persists, restore the DB from a backup taken on the same app version
Defensive patterns
Strategy: try-catch
Type guard
/** Any non-200 on /embeds (auth already handled by middleware) is a listing fault. */
function isEmbedsListFault(res) {
return res.status === 500;
} Try / catch
try {
const { embeds } = await listEmbeds();
} catch (e) {
if (e?.response?.status === 500)
throw new Error("embed listing failed — likely DB migration/schema issue; restart server and check logs");
throw e;
} Prevention
- Restart the server after every version upgrade before using admin pages
- Back up storage/anythingllm.db before upgrading so schema drift is recoverable
- Keep /embeds out of automated health checks; gate on logs instead
When it happens
Trigger: Opening the Embeddable Chat Widgets admin page after upgrading the app but before the DB schema was migrated; sqlite file locked or corrupted; storage volume mounted read-only; Prisma client binary missing for the platform.
Common situations: Pulling a new container image while keeping an old storage volume; moving the storage dir between hosts with different permissions; a crashed migration leaving half-applied schema changes.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/0fbb9daff2310e0a.
Report an issue: GitHub.
Appendix: source
Thrown at server/endpoints/embedManagement.js:29
const {
chatHistoryViewable,
} = require("../utils/middleware/chatHistoryViewable");
function embedManagementEndpoints(app) {
if (!app) return;
app.get(
"/embeds",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
async (_, response) => {
try {
const embeds = await EmbedConfig.whereWithWorkspace({}, null, {
createdAt: "desc",
});
response.status(200).json({ embeds });
} catch (e) {
console.error(e);
response.sendStatus(500).end();
}
}
);
app.post(
"/embeds/new",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
async (request, response) => {
try {
const user = await userFromSession(request, response);
const data = reqBody(request);
const { embed, message: error } = await EmbedConfig.new(data, user?.id);
await EventLogs.logEvent(
"embed_created",
{ embedId: embed.id },
user?.id
);
response.status(200).json({ embed, error });View on GitHub (pinned to 3aec848f28)