Mintplex-Labs/anything-llm · error · Error
Run not found
Error message
Run not found
What it means
Thrown by ScheduledJobRun.continueInThread(runId) when this.get({ id: Number(runId) }, { job: true }) returns null — i.e. no scheduled_job_runs row matches the supplied id. The function is meant to resume a finished scheduled-job run inside a workspace thread, so a missing run is a hard precondition failure. Number(runId) means non-numeric input becomes NaN and also matches nothing.
Source
Thrown at server/models/scheduledJobRun.js:312
return 0;
}
},
/**
* Continue a run in a workspace thread.
* This will create a new workspace and thread specific for the run if they do not exist, and add the run's response to the thread.
* @param {number} runId - The ID of the run to continue.
* @returns {Promise<{workspace: import("@prisma/client").workspaces | null, thread: import("@prisma/client").workspace_threads | null, error: string | null}>} A promise that resolves to an object containing the workspace, thread, and an error message if applicable.
*/
continueInThread: async function (runId) {
try {
const { Workspace } = require("./workspace");
const { WorkspaceThread } = require("./workspaceThread");
const { WorkspaceChats } = require("./workspaceChats");
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);View on GitHub (pinned to 526360e320)
Solutions
- Confirm the runId exists: query scheduled_job_runs for the id before calling continueInThread.
- Ensure runId is a parseable integer (Number.isFinite).
- Distinguish run id from job id — continueInThread wants the run id.
- Handle the returned { error: 'Run not found' } gracefully in the caller.
Example fix
// before
const { error } = await ScheduledJobRun.continueInThread(req.params.id);
// after
const runId = Number(req.params.id);
if (!Number.isFinite(runId)) return res.status(400).json({ error: 'Invalid run id' });
const { error } = await ScheduledJobRun.continueInThread(runId); Defensive patterns
Strategy: validation
Validate before calling
const runId = Number(input.runId);
if (!Number.isFinite(runId)) throw new Error('runId must be a finite integer');
const run = await ScheduledJobRun.get({ id: runId }, { job: true });
if (!run) throw new Error(`No scheduled run with id ${runId}`); Type guard
function isValidRunId(v) {
const n = Number(v);
return Number.isInteger(n) && n > 0;
} Try / catch
const { workspace, thread, error } = await ScheduledJobRun.continueInThread(runId);
if (error === 'Run not found') return res.status(404).json({ error }); Prevention
- Parse and validate runId as a positive integer before calling continueInThread.
- Distinguish run id from job id.
- Handle the returned error string rather than letting it surface raw.
When it happens
Trigger: Calling continueInThread with a runId that was deleted, never existed, or is not a valid number (NaN). Also when the run exists but the query's { job: true } join filter excludes it.
Common situations: Stale UI referencing a run deleted by cleanup; an id parsed from a URL string that included a prefix; race where the run was pruned between listing and continue; passing a job id instead of a run id.
Related errors
- Failed to create workspace
- Failed to create thread
- System prompt variable not found
- Failed to update default system prompt.
- File not found
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/8723654c3eff534e.
Report an issue: GitHub.