danny-avila/LibreChat · error · Error

No width provided

Error message

No width provided

What it means

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.

Source

Thrown at api/server/services/Files/process.js:1373

      }`,
    );
  }

  const isSupportedMimeType = fileConfig.checkType(
    file.mimetype,
    endpointFileConfig.supportedMimeTypes,
  );

  if (!isSupportedMimeType) {
    throw new Error('Unsupported file type');
  }

  if (!image || isAvatar === true) {
    return;
  }

  if (!width) {
    throw new Error('No width provided');
  }

  if (!height) {
    throw new Error('No height provided');
  }
}

module.exports = {
  filterFile,
  processFileURL,
  saveBase64Image,
  processImageFile,
  uploadImageBuffer,
  sweepExpiredFiles,
  startExpiredFileSweep,
  processFileUpload,
  processDeleteRequest,
  processAgentFileUpload,

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Read the selected image's natural dimensions client-side and append a positive integer width to the body.
  2. For formats without intrinsic dimensions (SVG), either rasterize first or pick an explicit width.
  3. Confirm you are sending width in the JSON body, not as a URL query parameter.

Example fix

// before
form.append('file_id', id);
form.append('endpoint', 'openAI');
// after
const img = await loadImage(blob);
form.append('file_id', id);
form.append('endpoint', 'openAI');
form.append('width', String(img.naturalWidth));
form.append('height', String(img.naturalHeight));
Defensive patterns

Strategy: validation

Validate before calling

async function readDims(blob) {
  const url = URL.createObjectURL(blob);
  const img = new Image();
  img.src = url;
  await img.decode();
  URL.revokeObjectURL(url);
  return { width: img.naturalWidth, height: img.naturalHeight };
}

Type guard

const hasPositiveWidth = (body) => Number.isFinite(+body?.width) && +body.width > 0;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/12c65861d9432e21. Report an issue: GitHub.