{"record":{"id":"2b447d010b045693","repo":"hcengineering/platform","slug":"file-too-large","errorCode":null,"errorMessage":"File too large","messagePattern":"File too large","errorType":"http","errorClass":null,"httpStatus":413,"severity":"error","filePath":"pods/server/src/server_http.ts","lineNumber":341,"sourceCode":"        if (authHeader === undefined) {\n          res.status(401).end(JSON.stringify({ error: 'Unauthorized' }))\n          return\n        }\n\n        const token = authHeader.split(' ')[1]\n        const wsIds = await getWorkspaceIds(token)\n\n        if (wsIds.uuid == null) {\n          res.status(403).end(JSON.stringify({ error: 'No workspace found' }))\n          return\n        }\n\n        const name = req.query.name as string\n        const contentType = req.query.contentType as string\n        const size = parseInt((req.query.size as string) ?? '-1')\n\n        if (size > MAX_FILE_SIZE) {\n          res.writeHead(413, { 'Content-Type': 'application/json', ...KEEP_ALIVE_HEADERS })\n          res.end(JSON.stringify({ error: 'File too large' }))\n          return\n        }\n        if (Number.isNaN(size)) {\n          ctx.error('/api/v1/blob put error', {\n            message: 'invalid NaN file size',\n            name,\n            workspace: wsIds.uuid\n          })\n          res.writeHead(404, { ...KEEP_ALIVE_HEADERS })\n          res.end()\n          return\n        }\n        await ctx.with(\n          'storage upload',\n          {},\n          async (ctx) => {\n            await externalStorage.put(","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/server/src/server_http.ts#L323-L359","documentation":"The message 'File too large' is returned with HTTP 413 by PUT /api/v1/blob when the client-declared size query parameter exceeds MAX_FILE_SIZE. The server validates the declared size up-front, before streaming the request body to external storage, to reject oversized uploads early.","triggerScenarios":"PUT /api/v1/blob?name=...&size=N where N (parsed from the size query param) is greater than MAX_FILE_SIZE; also size omitted yields -1 which is allowed, but any declared positive size above the cap triggers this.","commonSituations":"Uploading large video/model files to a workspace; client passing size in different units (KB vs bytes); MAX_FILE_SIZE lowered via config while clients still send old large files.","solutions":["Check the declared size query param and chunk or compress the file to stay under MAX_FILE_SIZE","Raise MAX_FILE_SIZE in server configuration if legitimate large uploads are required","Ensure the client reports the size in bytes, not KB/MB","Upload in multiple smaller blobs and reassemble client-side"],"exampleFix":"// before\nconst size = fs.statSync(path).size\nfetch(`/api/v1/blob?name=${name}&size=${size}`, { method: 'PUT', body: stream }) // 413 if too big\n// after\nif (size > MAX_FILE_SIZE) throw new Error('Split or compress file before upload')\nfetch(`/api/v1/blob?name=${name}&size=${size}`, { method: 'PUT', body: stream })","handlingStrategy":"validation","validationCode":"const size = fs.statSync(filePath).size\nif (size > MAX_FILE_SIZE) throw new Error(`file ${size} exceeds limit ${MAX_FILE_SIZE}; split or compress first`)","typeGuard":"const isWithinLimit = (size: unknown): size is number =>\n  typeof size === 'number' && Number.isFinite(size) && size <= MAX_FILE_SIZE","tryCatchPattern":"const res = await fetch(blobUrl, { method: 'PUT', body })\nif (res.status === 413) {\n  const body = await res.json().catch(() => null)\n  console.error('upload rejected:', body?.error)\n}","preventionTips":["Check file size client-side before every upload","Report size in bytes consistently","Keep client awareness of MAX_FILE_SIZE from server config","Chunk large files instead of uploading in one request"],"tags":["http","http-413","file-upload","size-limit"],"backgroundTag":"file-too-large","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}