{"record":{"id":"2a05d5600e30f418","repo":"transloadit/uppy","slug":"maxfilesize-exceeded","errorCode":null,"errorMessage":"maxFileSize exceeded","messagePattern":"maxFileSize exceeded","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/@uppy/companion/src/server/Uploader.ts","lineNumber":122,"sourceCode":"export class ValidationError extends Error {\n  override name = 'ValidationError'\n}\n\nfunction validateOptions(options: UploaderOptions): void {\n  // validate HTTP Method (optional)\n  if (options.httpMethod) {\n    if (typeof options.httpMethod !== 'string') {\n      throw new ValidationError('unsupported HTTP METHOD specified')\n    }\n\n    const method = options.httpMethod.toUpperCase()\n    if (method !== 'PUT' && method !== 'POST') {\n      throw new ValidationError('unsupported HTTP METHOD specified')\n    }\n  }\n\n  if (exceedsMaxFileSize(options.companionOptions.maxFileSize, options.size)) {\n    throw new ValidationError('maxFileSize exceeded')\n  }\n\n  // validate fieldname (optional)\n  if (options.fieldname != null && typeof options.fieldname !== 'string') {\n    throw new ValidationError('fieldname must be a string')\n  }\n\n  // validate metadata (optional)\n  if (options.metadata != null && typeof options.metadata !== 'object') {\n    throw new ValidationError('metadata must be an object')\n  }\n\n  // validate headers (optional)\n  if (options.headers != null && typeof options.headers !== 'object') {\n    throw new ValidationError('headers must be an object')\n  }\n\n  // validate protocol (optional)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/companion/src/server/Uploader.ts#L104-L140","documentation":"The file size passed to Uploader exceeds companionOptions.maxFileSize, so the upload is rejected before it starts. exceedsMaxFileSize compares options.size against the configured limit.","triggerScenarios":"new Uploader({ size: 50_000_000, companionOptions: { maxFileSize: 10_000_000 } }) — any size above the configured maxFileSize (a maxFileSize of -1/undefined means unlimited).","commonSituations":"Users selecting large files while the server default or explicit maxFileSize is lower; frontend limits not matching backend limits after a config change.","solutions":["Raise maxFileSize in the Companion options to accommodate the file","Enforce the same limit client-side so users see the error early","If unlimited uploads are intended, set maxFileSize: -1 (or omit it)"],"exampleFix":"// before\ncompanionOptions: { maxFileSize: 10_000_000 }\n\n// after\ncompanionOptions: { maxFileSize: 100_000_000 }","handlingStrategy":"validation","validationCode":"const max = companionOptions.maxFileSize\nif (max != null && max >= 0 && size > max) throw new Error('file too large')","typeGuard":"const exceeds = (size: number, max?: number) => max != null && max >= 0 && size > max","tryCatchPattern":"try { new Uploader(opts) } catch (e) { if (e instanceof ValidationError && /maxFileSize/.test(e.message)) return rejectFile(); throw e }","preventionTips":["Mirror server maxFileSize in client-side restrictions","Keep front-end and back-end limits in sync in shared config","Set maxFileSize: -1 only if unlimited is intended"],"tags":["companion","uploader","file-size","validation"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}