RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-file-type

error-invalid-file-type

Error message

Invalid file type: ${contentType}

What it means

Error "Invalid file type: ${contentType}" thrown in RocketChat/Rocket.Chat.

Source

Thrown at apps/meteor/server/lib/media/assets/assets.ts:240

	public async setAssetWithBuffer(
		file: Buffer,
		contentType: string,
		asset: string,
	): Promise<{
		key: string;
		value: IRocketChatAsset;
	}> {
		const assetInstance = getAssetByKey(asset);
		if (!assetInstance) {
			throw new Meteor.Error('error-invalid-asset', 'Invalid asset', {
				function: 'RocketChat.Assets.setAsset',
			});
		}

		const extension = getExtension(contentType);
		if (assetInstance.constraints.extensions.includes(extension) === false) {
			throw new Meteor.Error('error-invalid-file-type', `Invalid file type: ${contentType}`, {
				function: 'RocketChat.Assets.setAsset',
			});
		}

		if (assetInstance.constraints.width || assetInstance.constraints.height) {
			const dimensions = sizeOf(file);
			if (assetInstance.constraints.width && assetInstance.constraints.width !== dimensions.width) {
				throw new Meteor.Error('error-invalid-file-width', 'Invalid file width', {
					function: 'Invalid file width',
				});
			}
			if (assetInstance.constraints.height && assetInstance.constraints.height !== dimensions.height) {
				throw new Meteor.Error('error-invalid-file-height');
			}
		}

		const rs = RocketChatFile.bufferToStream(file);
		await RocketChatAssetsInstance.deleteFile(asset);

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Upload the file with a content type whose extension is listed in the asset's constraints.extensions.
  2. Convert the image to an accepted format (e.g. png, svg) and retry the upload.

When it happens

Trigger: Thrown at apps/meteor/server/lib/media/assets/assets.ts:240 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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