{"record":{"id":"f03e19e6687fd90b","repo":"different-ai/openwork","slug":"file-too-large","errorCode":"file_too_large","errorMessage":"Direct uploads support files up to ${DIRECT_UPLOAD_MAX_BYTES} bytes.","messagePattern":"Direct uploads support files up to (.+?) bytes\\.","errorType":"http","errorClass":"ApiError","httpStatus":413,"severity":"error","filePath":"apps/server/src/extensions/cloud-uploads.ts","lineNumber":134,"sourceCode":"  for (const root of roots) {\n    try {\n      pushUniqueResolvedPath(realRoots, await realpath(root));\n    } catch (error) {\n      if (!isRecord(error) || error.code !== \"ENOENT\") throw error;\n    }\n  }\n  const candidates = isAbsolute(requested)\n    ? [resolve(requested)]\n    : searchRoots(config, context, roots).map((root) => resolve(root, requested));\n  for (const candidate of candidates) {\n    if (!roots.some((root) => isWithinRoot(candidate, root))) continue;\n    try {\n      const realCandidate = await realpath(candidate);\n      if (!realRoots.some((root) => isWithinRoot(realCandidate, root))) continue;\n      const info = await stat(realCandidate);\n      if (!info.isFile()) continue;\n      if (info.size < 1 || info.size > DIRECT_UPLOAD_MAX_BYTES) {\n        throw new ApiError(413, \"file_too_large\", `Direct uploads support files up to ${DIRECT_UPLOAD_MAX_BYTES} bytes.`, {\n          size: info.size,\n          maxBytes: DIRECT_UPLOAD_MAX_BYTES,\n        });\n      }\n      return realCandidate;\n    } catch (error) {\n      if (isRecord(error) && error.code === \"ENOENT\") continue;\n      throw error;\n    }\n  }\n  throw new ApiError(404, \"file_not_found\", \"File was not found inside an authorized workspace root.\", { path: requested });\n}\n\nfunction mimeTypeForPath(path: string) {\n  const lower = path.toLowerCase();\n  if (lower.endsWith(\".pdf\")) return \"application/pdf\";\n  if (lower.endsWith(\".docx\")) return \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\";\n  if (lower.endsWith(\".xlsx\")) return \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\";","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/server/src/extensions/cloud-uploads.ts#L116-L152","documentation":"After resolving the file inside an authorized root, resolveAuthorizedFile stats it and enforces the DIRECT_UPLOAD_MAX_BYTES limit; files over the limit (and 0-byte files) get a 413 file_too_large ApiError.","triggerScenarios":"Direct-uploading a file whose stat size exceeds DIRECT_UPLOAD_MAX_BYTES, or an empty (0-byte) file, which is also rejected by the size < 1 check.","commonSituations":"Uploading large PDFs/videos/datasets via the direct upload path; symlinks resolving to big files; empty placeholder files created by scripts.","solutions":["Upload the file through the chunked/regular upload path instead of direct upload","Compress or split the file so it fits under DIRECT_UPLOAD_MAX_BYTES","Check the file isn't unexpectedly empty (size < 1 also triggers this) before uploading","Host the file externally and reference by URL if it's genuinely too large"],"exampleFix":"// before\nawait uploadDirect(largeVideoPath); // 500MB\n// after\nawait uploadChunked(largeVideoPath); // chunked path has its own limits","handlingStrategy":"validation","validationCode":"if (file.size > DIRECT_UPLOAD_MAX_BYTES) return useChunkedUpload(file);","typeGuard":null,"tryCatchPattern":"try { await uploadDirect(p); } catch (e) { if (e.code === \"file_too_large\") { await uploadChunked(p); } else throw e; }","preventionTips":["Compare size against the server-advertised max before upload","Auto-fallback to chunked upload","Skip 0-byte files at selection"],"tags":["uploads","file-size","http-413"],"backgroundTag":"file-too-large","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}