{"record":{"id":"bfb93796913f7843","repo":"Dokploy/dokploy","slug":"file-is-too-large-to-save-from-the-editor-max-512-bfb937","errorCode":null,"errorMessage":"File is too large to save from the editor (max 512KB)","messagePattern":"File is too large to save from the editor \\(max 512KB\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/server/src/services/docker.ts","lineNumber":841,"sourceCode":"\t\tthrow new Error(stderr);\n\t}\n\n\tconst buffer = Buffer.from(stdout.trim(), \"base64\");\n\treturn {\n\t\tcontent: buffer.subarray(0, CONTAINER_FILE_SIZE_LIMIT).toString(\"base64\"),\n\t\ttruncated: buffer.byteLength > CONTAINER_FILE_SIZE_LIMIT,\n\t};\n};\n\nexport const writeContainerFile = async (\n\tcontainerId: string,\n\tfilePath: string,\n\tcontent: string,\n\tserverId?: string,\n) => {\n\tconst base64Content = Buffer.from(content, \"utf8\").toString(\"base64\");\n\tif (base64Content.length > CONTAINER_FILE_SIZE_LIMIT * 2) {\n\t\tthrow new Error(\"File is too large to save from the editor (max 512KB)\");\n\t}\n\n\tconst tempPath = `/tmp/dokploy-edit-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n\tconst command = `printf '%s' ${quote([base64Content])} | base64 -d > ${quote([tempPath])} && docker cp ${quote([tempPath])} ${quote([`${containerId}:${filePath}`])}; status=$?; rm -f ${quote([tempPath])}; exit $status`;\n\n\tif (serverId) {\n\t\tawait execAsyncRemote(serverId, command);\n\t} else {\n\t\tawait execAsync(command);\n\t}\n};\n\nexport const deleteContainerFile = async (\n\tcontainerId: string,\n\tpath: string,\n\tserverId?: string,\n) => {\n\tconst command = `docker exec ${quote([containerId])} rm -rf ${quote([path])}`;","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/docker.ts#L823-L859","documentation":"Thrown when saving a file from the Dokploy editor into a container: the UTF-8 content, once base64-encoded, exceeds CONTAINER_FILE_SIZE_LIMIT * 2 bytes (base64 is ~4/3 the size of the raw content, so the effective raw limit is 512KB). This is a deliberate guard so the generated shell printf/base64 pipeline stays within ARG_MAX and docker cp limits.","triggerScenarios":"Calling saveFileToContainer (editor save endpoint) with content whose base64 representation exceeds ~1MB (raw content > 512KB), e.g. pasting a large JSON/CSV/lockfile into the editor and hitting save.","commonSituations":"Editing generated files like package-lock.json, minified bundles, or dataset files in the built-in editor; machine-generated content pasted in exceeds the cap even though the on-disk file was small when opened truncated.","solutions":["Edit the file outside the editor (docker cp it out, edit locally, docker cp back)","Reduce the file content below 512KB before saving","If you own the deployment, raise CONTAINER_FILE_SIZE_LIMIT and rebuild the server, understanding shell ARG_MAX constraints"],"exampleFix":"// before\nawait saveFileToContainer(containerId, filePath, hugeContent, serverId);\n// after\n// stream via docker cp instead of the editor for large files\nawait execAsync(`docker cp ${localLargeFile} ${containerId}:${filePath}`);","handlingStrategy":"validation","validationCode":"const MAX = 512 * 1024;\nif (Buffer.byteLength(content, 'utf8') > MAX) throw new RangeError('use docker cp for large files');","typeGuard":null,"tryCatchPattern":"try { await saveFileToContainer(id, path, content, serverId); }\ncatch (e) { if ((e as Error).message.includes('too large')) { /* docker cp fallback */ } throw e; }","preventionTips":["Measure byte length (not string length) before saving","Use docker cp workflows for generated/large artifacts","Warn users in the editor near the size cap"],"tags":["docker","file-size","editor","limit"],"backgroundTag":"payload-too-large","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}