{"record":{"id":"59deeb13b3437b4f","repo":"Mintplex-Labs/anything-llm","slug":"workspace-not-found","errorCode":null,"errorMessage":"Workspace not found","messagePattern":"Workspace not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/models/workspacesSuggestedMessages.js","lineNumber":35,"sourceCode":"    try {\n      const messages = await prisma.workspace_suggested_messages.findMany({\n        where: clause,\n        take: limit || undefined,\n      });\n      return messages;\n    } catch (error) {\n      console.error(error.message);\n      return [];\n    }\n  },\n\n  saveAll: async function (messages, workspaceSlug) {\n    try {\n      const workspace = await prisma.workspaces.findUnique({\n        where: { slug: workspaceSlug },\n      });\n\n      if (!workspace) throw new Error(\"Workspace not found\");\n\n      // Delete all existing messages for the workspace\n      await prisma.workspace_suggested_messages.deleteMany({\n        where: { workspaceId: workspace.id },\n      });\n\n      // Create new messages\n      // We create each message individually because prisma\n      // with sqlite does not support createMany()\n      for (const message of messages) {\n        await prisma.workspace_suggested_messages.create({\n          data: {\n            workspaceId: workspace.id,\n            heading: message.heading,\n            message: message.message,\n          },\n        });\n      }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/models/workspacesSuggestedMessages.js#L17-L53","documentation":"Thrown by WorkspaceSuggestedMessages.saveAll when no workspace matches the provided slug (prisma.workspaces.findUnique by slug returns null). Reached via POST /workspace/:slug/suggested-messages. Note: this error is caught and only console.error-logged; the function returns void and the endpoint still responds 200 success, so the caller never sees the failure.","triggerScenarios":"POST /workspace/:slug/suggested-messages where the slug does not correspond to any workspace (deleted, renamed, typo, or wrong instance). The middleware validWorkspaceSlug is not on this route, so the lookup is the only guard.","commonSituations":"Workspace was deleted or its slug changed after the page loaded. Cross-instance slug copy. Race between workspace deletion and a lingering UI save.","solutions":["Confirm the workspace slug still exists before saving suggested messages.","Add the validWorkspaceSlug middleware to this route so a bad slug is rejected with 404 instead of silently swallowed.","Refresh the workspace list in the UI before editing its suggested messages."],"exampleFix":"// before (error swallowed, endpoint returns 200)\nawait WorkspaceSuggestedMessages.saveAll(messages, slug);\nreturn response.status(200).json({ success: true });\n// after (surface the failure)\nconst workspace = await Workspace.get({ slug });\nif (!workspace) return response.status(404).json({ success: false, message: 'Workspace not found' });\nawait WorkspaceSuggestedMessages.saveAll(messages, slug);","handlingStrategy":"validation","validationCode":"const workspace = await prisma.workspaces.findUnique({ where: { slug: workspaceSlug } });\nif (!workspace) return respond(404, 'Workspace not found');\nawait WorkspaceSuggestedMessages.saveAll(messages, workspaceSlug);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add the validWorkspaceSlug middleware to the save route so bad slugs are rejected explicitly.","Because saveAll swallows the error, check workspace existence yourself before calling.","Refresh the workspace list before editing suggested messages."],"tags":["workspace","suggested-messages","silent-failure","not-found"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}