{"record":{"id":"7b750ded682e2322","repo":"Mintplex-Labs/anything-llm","slug":"memory-is-already-workspace-scoped","errorCode":null,"errorMessage":"Memory is already workspace-scoped.","messagePattern":"Memory is already workspace-scoped\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"info","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":"Idempotency message from Memory.demoteToWorkspace when the memory's scope is already 'workspace'. The model returns {memory: existing, message}, and the endpoint only 400s on memory:null — so the HTTP response is actually 200 with the memory; this message appears only in logs/tests, never as an error body.","triggerScenarios":"POST /memories/:id/demote/:slug on a memory already scoped to a workspace — double-submit of Demote or a stale UI.","commonSituations":"Demote button clicked twice; another client demoted the same memory first; retry of an already-succeeded demote.","solutions":["Nothing to fix — the request succeeds (200) and returns the memory","Hide/disable Demote when the loaded memory has scope 'workspace'","Safe to ignore in automation; idempotent by design"],"exampleFix":"// before\nif (memory) showDemoteButton();\n// after\nif (memory && memory.scope !== 'workspace') showDemoteButton();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isDemotable(memory) {\n  return memory !== null && memory.scope === 'global'; // only global memories can demote\n}","tryCatchPattern":null,"preventionTips":["Only render Demote for memories with scope 'global'","Sync local state from mutation responses so actions never go stale","Know this path is idempotent — endpoint returns 200 with the memory, not 400"],"tags":["memory","idempotent","demote"],"backgroundTag":"idempotent-no-op","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"}