{"record":{"id":"79c8d7317e9ac3a2","repo":"danny-avila/LibreChat","slug":"file-size-limit-of-filesizelimit-megabyte-mb","errorCode":null,"errorMessage":"File size limit of ${fileSizeLimit / megabyte} MB exceeded for ${isAvatar ? 'avatar upload' : `${endpoint} endpoint`}","messagePattern":"File size limit of (.+?) MB exceeded for (.+?) endpoint`\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/server/services/Files/process.js","lineNumber":1352,"sourceCode":"  }\n\n  if (!endpoint && !isAvatar) {\n    throw new Error('No endpoint provided');\n  }\n\n  const appConfig = req.config;\n  const fileConfig = mergeFileConfig(appConfig.fileConfig);\n\n  const endpointFileConfig = getEndpointFileConfig({\n    endpoint,\n    fileConfig,\n    endpointType,\n  });\n  const fileSizeLimit =\n    isAvatar === true ? fileConfig.avatarSizeLimit : endpointFileConfig.fileSizeLimit;\n\n  if (file.size > fileSizeLimit) {\n    throw new Error(\n      `File size limit of ${fileSizeLimit / megabyte} MB exceeded for ${\n        isAvatar ? 'avatar upload' : `${endpoint} endpoint`\n      }`,\n    );\n  }\n\n  const isSupportedMimeType = fileConfig.checkType(\n    file.mimetype,\n    endpointFileConfig.supportedMimeTypes,\n  );\n\n  if (!isSupportedMimeType) {\n    throw new Error('Unsupported file type');\n  }\n\n  if (!image || isAvatar === true) {\n    return;\n  }","sourceCodeStart":1334,"sourceCodeEnd":1370,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/process.js#L1334-L1370","documentation":"filterFile() throws this at process.js:1352 after computing fileSizeLimit from the merged fileConfig: avatarSizeLimit for avatars, otherwise endpointFileConfig.fileSizeLimit. The limit is bytes; the message renders it as MB (fileSizeLimit / megabyte). This protects against oversized uploads before any disk or remote storage write.","triggerScenarios":"Any upload whose req.file.size exceeds the configured limit for that endpoint or for avatars. Triggered after file_id/endpoint validation and before MIME-type checking, so only correctly-addressed oversize files reach it.","commonSituations":"librechat.yaml fileConfig endpointsSizeLimit/avatars.sizeLimit set lower than the user's file. A user uploading a 4K screenshot to an endpoint capped at 1 MB. Default limits after an upgrade that tightened them.","solutions":["Reduce the file size (compress/resize images, trim audio) below the limit shown in the message.","If the limit is wrong, raise fileSizeLimit for that endpoint or avatarSizeLimit in librechat.yaml and restart the API.","Confirm the endpoint you are uploading to is the one whose limit you configured."],"exampleFix":"// librechat.yaml before\nfileConfig:\n  endpointsSizeLimit: Default,1\n// after\nfileConfig:\n  endpointsSizeLimit: Default,10","handlingStrategy":"validation","validationCode":"function withinSizeLimit(file, limitBytes) {\n  return file.size <= limitBytes;\n}\n// before upload:\nif (!withinSizeLimit(selectedFile, endpointLimitBytes)) {\n  notifyUser(`File exceeds ${endpointLimitBytes / 1e6} MB`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read endpoint limits from the server config and enforce client-side before upload.","Show the limit in the file picker UI so users self-select compliant files."],"tags":["files","validation","config","limits"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}