{"record":{"id":"12c65861d9432e21","repo":"danny-avila/LibreChat","slug":"no-width-provided","errorCode":null,"errorMessage":"No width provided","messagePattern":"No width provided","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/server/services/Files/process.js","lineNumber":1373,"sourceCode":"      }`,\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  }\n\n  if (!width) {\n    throw new Error('No width provided');\n  }\n\n  if (!height) {\n    throw new Error('No height provided');\n  }\n}\n\nmodule.exports = {\n  filterFile,\n  processFileURL,\n  saveBase64Image,\n  processImageFile,\n  uploadImageBuffer,\n  sweepExpiredFiles,\n  startExpiredFileSweep,\n  processFileUpload,\n  processDeleteRequest,\n  processAgentFileUpload,","sourceCodeStart":1355,"sourceCodeEnd":1391,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/process.js#L1355-L1391","documentation":"filterFile() throws this at process.js:1373 when image is true, the upload is not an avatar, and req.body.width is falsy. Image uploads require width/height because the server resizes and stores dimensions in the file record. The avatar path returns early before this check, and non-image paths return early too.","triggerScenarios":"POST /api/files/images whose body omits width, sends width:0, or sends width under a wrong key (e.g. w). Reached only after file_id, size, and MIME checks pass for an image upload.","commonSituations":"Frontend reads an <img> naturalWidth lazily and the field is undefined when FormData is built. A custom client treating width as optional. Image dimension detection that fails for SVG and yields 0.","solutions":["Read the selected image's natural dimensions client-side and append a positive integer width to the body.","For formats without intrinsic dimensions (SVG), either rasterize first or pick an explicit width.","Confirm you are sending width in the JSON body, not as a URL query parameter."],"exampleFix":"// before\nform.append('file_id', id);\nform.append('endpoint', 'openAI');\n// after\nconst img = await loadImage(blob);\nform.append('file_id', id);\nform.append('endpoint', 'openAI');\nform.append('width', String(img.naturalWidth));\nform.append('height', String(img.naturalHeight));","handlingStrategy":"validation","validationCode":"async function readDims(blob) {\n  const url = URL.createObjectURL(blob);\n  const img = new Image();\n  img.src = url;\n  await img.decode();\n  URL.revokeObjectURL(url);\n  return { width: img.naturalWidth, height: img.naturalHeight };\n}","typeGuard":"const hasPositiveWidth = (body) => Number.isFinite(+body?.width) && +body.width > 0;","tryCatchPattern":null,"preventionTips":["Set width and height together from a single dimension-read helper.","Reject SVGs or rasterize them so dimensions are always defined."],"tags":["files","validation","images","upload"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}