Mintplex-Labs/anything-llm · error · Error
Failed to create workspace
Error message
Failed to create workspace
What it means
Thrown by continueInThread when Workspace.upsert({ slug: 'scheduled-jobs' }, ...) returns a non-null workspaceError. The fallback text only appears if workspaceError is an empty/falsy-but-present string; normally the actual error message propagates. This means creating or finding the dedicated 'Scheduled Jobs' workspace failed.
Source
Thrown at server/models/scheduledJobRun.js:327
const { safeJsonParse } = require("../utils/http");
const run = await this.get({ id: Number(runId) }, { job: true });
if (!run) throw new Error("Run not found");
const result = safeJsonParse(run.result, {});
const responseText = result?.text || "No response was generated.";
// Get or create the "Scheduled Jobs" workspace
const { workspace, error: workspaceError } = await Workspace.upsert(
{ slug: "scheduled-jobs" },
{
name: "Scheduled Jobs",
slug: "scheduled-jobs",
chatMode: "automatic",
}
);
if (workspaceError)
throw new Error(workspaceError || "Failed to create workspace");
const { thread, message: threadError } =
await WorkspaceThread.new(workspace);
if (threadError)
throw new Error(threadError || "Failed to create thread");
await WorkspaceChats.new({
workspaceId: workspace.id,
prompt: run.job.prompt,
response: {
text: responseText,
sources: result.sources || [],
outputs: result.outputs || [],
type: "chat",
},
threadId: thread.id,
include: true,
});View on GitHub (pinned to 526360e320)
Solutions
- Read the propagated workspaceError string in the returned { error } for the real cause.
- Check DB connectivity and that the workspaces table exists.
- Inspect for duplicate slug 'scheduled-jobs' rows and deduplicate.
- Run pending Prisma migrations.
Defensive patterns
Strategy: try-catch
Try / catch
const { workspace, error } = await ScheduledJobRun.continueInThread(runId);
if (error && /create workspace/i.test(error)) {
logger.error('Scheduled-jobs workspace upsert failed', { runId, error });
return res.status(503).json({ error: 'Could not create the Scheduled Jobs workspace. Retry later.' });
} Prevention
- Keep DB connectivity healthy and migrations applied.
- Deduplicate any 'scheduled-jobs' slug rows.
- Surface the propagated workspaceError string in logs.
When it happens
Trigger: The database is unreachable, the workspaces table/unique constraint on slug is in a bad state, or Workspace.upsert's internal create/update logic threw. The 'scheduled-jobs' slug already exists under a different shape causing a conflict.
Common situations: DB connection failure mid-request; a prior partial migration left duplicate 'scheduled-jobs' slugs; Prisma unique-constraint violation; the upsert helper returned an error string from a nested validation.
Related errors
- Run not found
- Failed to create thread
- Internal Server Error
- res.statusText || "Error setting watch status for document."
- Error setting suggested messages.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/1cb1429f22d338c7.
Report an issue: GitHub.