{"record":{"id":"bb5a43375fda88ad","repo":"Mintplex-Labs/anything-llm","slug":"no-workspace-found-or-could-be-created","errorCode":null,"errorMessage":"No workspace found or could be created.","messagePattern":"No workspace found or could be created\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/telegram.js","lineNumber":115,"sourceCode":"        }\n\n        let workspaceSlug = null;\n        if (default_workspace) workspaceSlug = String(default_workspace);\n        else {\n          const workspaces = await Workspace.where({}, 1);\n          if (workspaces.length) workspaceSlug = workspaces[0].slug;\n          else {\n            const { workspace } = await Workspace.new(\n              `${verification.username} Workspace`,\n              null,\n              { chatMode: \"automatic\" }\n            );\n            if (workspace) workspaceSlug = workspace.slug;\n          }\n        }\n\n        if (!workspaceSlug) {\n          return response.status(400).json({\n            success: false,\n            error: \"No workspace found or could be created.\",\n          });\n        }\n\n        // Preserve approved users when reconnecting with a new token\n        const existing = await ExternalCommunicationConnector.get(\"telegram\");\n        const storedConfig = {\n          bot_username: verification.username,\n          default_workspace: workspaceSlug,\n          approved_users: existing?.config?.approved_users || [],\n          voice_response_mode:\n            existing?.config?.voice_response_mode || \"text_only\",\n        };\n\n        // Save config with encrypted token\n        const { error } = await ExternalCommunicationConnector.upsert(\n          \"telegram\",","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/telegram.js#L97-L133","documentation":"Returned by POST /telegram/connect when no default workspace slug could be resolved. The endpoint first checks for any existing workspace (Workspace.where({}, 1)); if none exists it tries to create one named '<bot_username> Workspace'. If both the lookup is empty and Workspace.new() yields no workspace, the Telegram connector cannot be bound to a workspace and the request fails with 400.","triggerScenarios":"Connecting Telegram on a fresh or wiped instance where the default workspace was deleted and every other workspace is gone, while the implicit Workspace.new() also fails (database write error, locked SQLite file, invalid slug generated from the bot username, disk full).","commonSituations":"Single-user instance after the user deleted all workspaces; corrupted or read-only storage folder (anythingllm.db permissions); first-run where workspace bootstrap failed earlier; bot username containing characters that break slug creation.","solutions":["Create a workspace first via the UI or POST /api/workspace, then retry POST /telegram/connect - the endpoint will pick workspaces[0].slug automatically.","If workspace creation persistently fails, inspect server logs around Workspace.new and check the database file/directory permissions and disk space.","As a workaround, pass default_workspace explicitly in the connect request body to target a known-good workspace slug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before connecting Telegram, guarantee a workspace exists\nconst res = await fetch(\"/api/workspace\", { method: \"POST\", headers, body: JSON.stringify({ name: \"Default\" }) });\n// then POST /telegram/connect with { default_workspace: \"<created slug>\" } to skip implicit resolution entirely.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass default_workspace explicitly in the connect body instead of relying on implicit first-workspace resolution.","Keep at least one workspace on the instance at all times.","Investigate persistent Workspace.new failures immediately - they point at database/permission problems that will break more than Telegram."],"tags":["telegram","workspace","database","onboarding"],"backgroundTag":"resource-creation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}