RocketChat/Rocket.Chat · error

File name is required

Error message

File name is required

What it means

Client-side validation in the Save-to-WebDAV modal: after fetching the attachment bytes as an ArrayBuffer, the upload needs a file name, which is taken from the attachment's title field. If the attachment carries no title, the upload is aborted before uploadFileToWebdav is called and the toast shows this error.

Source

Thrown at apps/meteor/client/views/room/webdav/SaveToWebdavModal.tsx:77

	useEffect(() => fileRequest.current?.abort, []);

	const handleSaveFile = ({ accountId }: { accountId: IWebdavAccount['_id'] }): void => {
		setIsLoading(true);

		const {
			url,
			attachment: { title },
		} = data;

		fileRequest.current = new XMLHttpRequest();
		fileRequest.current.open('GET', url, true);
		fileRequest.current.responseType = 'arraybuffer';
		fileRequest.current.onload = async (): Promise<void> => {
			const arrayBuffer = fileRequest.current?.response;
			if (arrayBuffer) {
				try {
					if (!title) {
						throw new Error('File name is required');
					}
					const response = await uploadFileToWebdav(accountId, arrayBuffer, title);
					if (!response.success) {
						throw new Error(response.message ? t(response.message) : 'Error uploading file');
					}
					return dispatchToastMessage({ type: 'success', message: t('File_uploaded') });
				} catch (error) {
					return dispatchToastMessage({ type: 'error', message: error });
				} finally {
					setIsLoading(false);
					onClose();
				}
			}
		};
		fileRequest.current.send(null);
	};

	return (

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Ensure the attachment object includes a non-empty title (file name) — fix the app/webhook that posts the attachment
  2. If you own the sending code, set attachment.title to the desired file name
  3. As a code improvement, fall back to a name derived from the URL when title is missing

Example fix

// before
if (!title) {
	throw new Error('File name is required');
}
const response = await uploadFileToWebdav(accountId, arrayBuffer, title);

// after: derive a fallback name
const fileName = title || new URL(url).pathname.split('/').pop() || 'file';
const response = await uploadFileToWebdav(accountId, arrayBuffer, fileName);
Defensive patterns

Strategy: validation

Validate before calling

if (!attachment?.title) {
	// do not even open the WebDAV flow without a file name
	dispatchToastMessage({ type: 'error', message: 'Attachment has no file name' });
	return;
}

Type guard

const hasFileName = (a?: { title?: string }): a is { title: string } =>
	typeof a?.title === 'string' && a.title.length > 0;

Prevention

When it happens

Trigger: Choosing 'Save to WebDAV' on a message attachment whose title is empty or undefined: attachments synthesized by Apps Engine apps, incoming webhooks, or bridges that only set image/file URLs (title_link, image_url) without a title string.

Common situations: Bot/app-generated attachments without title, older messages or federation-bridged attachments dropping the title field, custom integrations posting attachments with only a URL.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/097a42c5b7341a69. Report an issue: GitHub.