{"record":{"id":"56774cb6902fb902","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-56774c","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/api/workspaceThread/index.js","lineNumber":106,"sourceCode":"          workspace,\n          userId ? Number(userId) : null,\n          { name, slug }\n        );\n\n        await Telemetry.sendTelemetry(\"workspace_thread_created\", {\n          multiUserMode: multiUserMode(response),\n          LLMSelection: process.env.LLM_PROVIDER || \"openai\",\n          Embedder: process.env.EMBEDDING_ENGINE || \"inherit\",\n          VectorDbSelection: process.env.VECTOR_DB || \"lancedb\",\n          TTSSelection: process.env.TTS_PROVIDER || \"native\",\n        });\n        await EventLogs.logEvent(\"api_workspace_thread_created\", {\n          workspaceName: workspace?.name || \"Unknown Workspace\",\n        });\n        response.status(200).json({ thread, message });\n      } catch (e) {\n        console.error(e.message, e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.post(\n    \"/v1/workspace/:slug/thread/:threadSlug/update\",\n    [validApiKey],\n    async (request, response) => {\n      /*\n      #swagger.tags = ['Workspace Threads']\n      #swagger.description = 'Update thread name by its unique slug.'\n      #swagger.parameters['slug'] = {\n          in: 'path',\n          description: 'Unique slug of workspace',\n          required: true,\n          type: 'string'\n      }\n      #swagger.parameters['threadSlug'] = {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/f92433b4ea0598492a1e6645ea22addbb4dd1287/server/endpoints/api/workspaceThread/index.js#L88-L124","documentation":"The catch-all 500 for POST /v1/workspace/:slug/thread/new. The workspace check (400) already passed, and WorkspaceThread.new catches its own Prisma errors internally (returning {thread:null, message}), so this 500 fires only when something outside those guarded calls rejects — most commonly a database engine fault (SQLITE_BUSY/locked sqlite file, Prisma engine crash, unreadable storage dir) or a response serialization failure. The handler logs e.message to the server console.","triggerScenarios":"SQLite database file locked by a concurrent process (backup job, two server instances on one storage dir), disk full so Prisma cannot write, storage/ permissions broken after a container migration, or prisma client out of sync with the schema (schema drift after upgrading without restarting).","commonSituations":"Running dev server and a worker against the same storage dir; docker volume permission changes (chown'ed storage); upgrading the app image but keeping an old database file that needs migration; extremely rapid parallel thread creations hitting sqlite write locks.","solutions":["Check the server console line printed by console.error(e.message, e) — it names the underlying Prisma/SQLite error","Ensure only one server process uses the storage directory at a time and nothing else holds the sqlite file","Verify disk space and storage/ directory permissions for the server process user","Restart the container after upgrades so pending Prisma migrations/schema sync run"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"/** 500 from this endpoint is a server fault, not a client error. */\nfunction isServerFault(res) {\n  return res.status === 500;\n}","tryCatchPattern":"try {\n  const { thread, message } = await createThread(slug, body);\n} catch (e) {\n  if (e?.response?.status === 500)\n    throw new Error(\"thread creation failed server-side — check server logs (likely DB locked/corrupt)\");\n  throw e;\n}","preventionTips":["Serialize thread creations instead of firing them in parallel to avoid sqlite write-lock storms","Keep one server process per storage directory","Alert on any 500 from this endpoint — the underlying DB error is only visible server-side"],"tags":["http-500","workspace-thread","sqlite","prisma","api"],"backgroundTag":"database-query-failed","analyzedSha":"f92433b4ea0598492a1e6645ea22addbb4dd1287","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}