{"record":{"id":"02b26a8f85029fac","repo":"Mintplex-Labs/anything-llm","slug":"maximum-global-memory-limit-this-global-limit","errorCode":null,"errorMessage":"Maximum global memory limit (${this.GLOBAL_LIMIT}) reached.","messagePattern":"Maximum global memory limit \\((.+?)\\) reached\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/memory.js","lineNumber":157,"sourceCode":"        console.error(e);\n        return response.sendStatus(500);\n      }\n    }\n  );\n\n  app.post(\n    \"/memories/:memoryId/promote\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validateMemoryOwner,\n    ],\n    async (request, response) => {\n      try {\n        const memoryId = Number(request.params.memoryId);\n        const { memory, message } = await Memory.promoteToGlobal(memoryId);\n        if (!memory) return response.status(400).json({ error: message });\n\n        response.status(200).json({ memory });\n      } catch (e) {\n        console.error(e);\n        return response.sendStatus(500);\n      }\n    }\n  );\n\n  app.post(\n    \"/memories/:memoryId/demote/:slug\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validateMemoryOwner,\n      validWorkspaceSlug,\n    ],","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/memory.js#L139-L175","documentation":"400 from POST /memories/:memoryId/promote. Promoting a workspace memory would exceed the per-user global cap of 5 (Memory.GLOBAL_LIMIT); promoteToGlobal counts the user's existing global memories and refuses without modifying the row.","triggerScenarios":"POST /memories/:id/promote when the owning user already has 5 global-scoped memories (userId-scoped count, null in single-user mode).","commonSituations":"Consolidating many workspace memories upward; forgetting the global cap (5) is much tighter than the workspace cap (20).","solutions":["Demote or delete a global memory to free a slot, then promote again","Keep the memory workspace-scoped if it does not need cross-workspace effect","Raise Memory.GLOBAL_LIMIT in server/models/memory.js if the deployment genuinely needs more"],"exampleFix":"// before\nawait fetch(`/memories/${id}/promote`, { method: 'POST' });\n// after\nconst globals = memories.filter((m) => m.scope === 'global');\nif (globals.length >= 5) { alert('Global memory limit (5) reached — demote one first'); return; }\nawait fetch(`/memories/${id}/promote`, { method: 'POST' });","handlingStrategy":"validation","validationCode":"const globalCount = memories.filter((m) => m.scope === 'global').length;\nif (globalCount >= 5) throw new Error('Global memory limit (5) reached — demote or delete one first');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Track the user's global count (cap 5) in the UI before offering Promote","Guide users to demote the least-useful global memory instead of hitting the wall","The cap is per-user, so counts differ across accounts in multi-user mode"],"tags":["memory","quota","promote","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-14T00:17:10.932Z"}