{"record":{"id":"31ca46173bccca64","repo":"Mintplex-Labs/anything-llm","slug":"maximum-workspace-memory-limit-this-workspace-l","errorCode":null,"errorMessage":"Maximum workspace memory limit (${this.WORKSPACE_LIMIT}) reached.","messagePattern":"Maximum workspace memory limit \\((.+?)\\) reached\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/memory.js","lineNumber":186,"sourceCode":"    \"/memories/:memoryId/demote/:slug\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validateMemoryOwner,\n      validWorkspaceSlug,\n    ],\n    async (request, response) => {\n      try {\n        const memoryId = Number(request.params.memoryId);\n        const targetWorkspace = response.locals.workspace;\n\n        const { memory, message } = await Memory.demoteToWorkspace(\n          memoryId,\n          targetWorkspace.id\n        );\n\n        if (!memory) return response.status(400).json({ error: message });\n        response.status(200).json({ memory });\n      } catch (e) {\n        console.error(e);\n        return response.sendStatus(500);\n      }\n    }\n  );\n}\n\nmodule.exports = { memoryEndpoints };\n","sourceCodeStart":168,"sourceCodeEnd":197,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/memory.js#L168-L197","documentation":"400 from POST /memories/:memoryId/demote/:slug. Demoting a global memory into the target workspace would exceed WORKSPACE_LIMIT (20 per user per workspace); demoteToWorkspace counts that workspace's memories for the user and refuses without writing.","triggerScenarios":"POST /memories/:id/demote/:slug when the target workspace (resolved from :slug via validWorkspaceSlug) already holds 20 workspace-scoped memories for this user.","commonSituations":"Moving several global memories into an already-full workspace; bulk demote scripts ignoring per-workspace caps.","solutions":["Delete or demote-out some memories in the target workspace first","Keep the memory global if that workspace is full","Raise Memory.WORKSPACE_LIMIT if the deployment needs a larger cap"],"exampleFix":"// before\nawait fetch(`/memories/${id}/demote/${slug}`, { method: 'POST' });\n// after\nconst wsCount = memories.filter((m) => m.scope === 'workspace' && m.workspaceId === targetWs.id).length;\nif (wsCount >= 20) { alert('Workspace memory limit (20) reached'); return; }\nawait fetch(`/memories/${id}/demote/${slug}`, { method: 'POST' });","handlingStrategy":"validation","validationCode":"const wsCount = memories.filter((m) => m.scope === 'workspace' && m.workspaceId === targetWorkspace.id).length;\nif (wsCount >= 20) throw new Error('Target workspace memory limit (20) reached — remove one first');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the target workspace's count (cap 20 per user) before offering Demote into it","Bulk demote scripts should stop at the cap, not fire all moves","The cap is per user per workspace — a full workspace for one user may be empty for another"],"tags":["memory","quota","demote","http-400"],"backgroundTag":"resource-limit-exceeded","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"}