{"record":{"id":"2fe0cca09b9e8f96","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-move-files-2fe0cc","errorCode":null,"errorMessage":"Failed to move files.","messagePattern":"Failed to move files\\.","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/document.js","lineNumber":104,"sourceCode":"                message: `${unmovableCount}/${files.length} files not moved. Unembed them from all workspaces.`,\n              });\n            } else {\n              response.status(200).json({\n                success: true,\n                message: null,\n              });\n            }\n          })\n          .catch((err) => {\n            console.error(\"Error moving files:\", err);\n            response\n              .status(500)\n              .json({ success: false, message: \"Failed to move some files.\" });\n          });\n      } catch (e) {\n        console.error(e);\n        response\n          .status(500)\n          .json({ success: false, message: \"Failed to move files.\" });\n      }\n    }\n  );\n}\n\nmodule.exports = { documentEndpoints };\n","sourceCodeStart":86,"sourceCodeEnd":112,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/document.js#L86-L112","documentation":"Outer synchronous catch for POST /document/move-files. Fires when setup fails before the move promises are even created — typically reqBody shape is wrong (files missing or not an array, so .filter/.map throws a TypeError) or the embedded-files lookup for the workspace throws (DB error). Distinct from error 683, which fires on async rename failures.","triggerScenarios":"Calling /document/move-files with a body where files is null/undefined/not an array, or sending form-encoded instead of JSON so reqBody parsing yields an unexpected shape; a Prisma/DB failure while listing embedded files.","commonSituations":"Client sends {files: null} or omits the field; hand-rolled scripts posting the wrong content type; database briefly unreachable.","solutions":["Confirm the request is JSON with shape {files: [{from: 'a.pdf', to: 'sub/a.pdf'}, ...]}","Check the server console — the caught exception (usually a TypeError) is printed with the stack","Retry with a single-element files array to isolate the failing input","If the console shows a DB error, resolve database connectivity first"],"exampleFix":"// before\nawait fetch('/document/move-files', { method: 'POST', body: JSON.stringify({ files: maybeFiles }) });\n// after\nif (!Array.isArray(maybeFiles) || maybeFiles.some((f) => !f?.from || !f?.to))\n  throw new Error('files must be an array of {from, to}');\nawait fetch('/document/move-files', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ files: maybeFiles }) });","handlingStrategy":"validation","validationCode":"// Enforce request shape before the call\nif (!Array.isArray(files) || files.some((f) => typeof f?.from !== 'string' || typeof f?.to !== 'string'))\n  throw new Error('files must be an array of {from, to} strings');\nawait fetch('/document/move-files', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ files }) });","typeGuard":"function isMoveFilesPayload(p) {\n  return typeof p === 'object' && p !== null && Array.isArray(p.files)\n    && p.files.every((f) => typeof f?.from === 'string' && typeof f?.to === 'string');\n}","tryCatchPattern":null,"preventionTips":["Always send Content-Type: application/json with {files:[{from,to}]}","Validate payload shape client-side — the outer 500 is almost always a TypeError from bad shape","Distinguish outer 'Failed to move files.' (setup) from inner 'Failed to move some files.' (rename failures)"],"tags":["documents","file-move","bad-request","http-500"],"backgroundTag":"request-body-validation-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"}