RocketChat/Rocket.Chat · error · Meteor.Error

emoji-is-not-image

emoji-is-not-image

Error message

Emoji file provided cannot be uploaded since it's not an image

What it means

Thrown by POST emoji-custom.create when Media.isImage(fileBuffer) returns false — the uploaded bytes are not a recognizable image. The endpoint reads the multipart 'emoji' field and inspects actual content, not the declared mimetype, so renaming a non-image file to .png will still fail.

Source

Thrown at apps/meteor/server/api/v1/emoji-custom.ts:202

				401: validateUnauthorizedErrorResponse,
			},
		},
		async function action() {
			const emoji = await getUploadFormData(
				{
					request: this.request,
				},
				{
					field: 'emoji',
					sizeLimit: settings.get('FileUpload_MaxFileSize'),
				},
			);

			const { fields, fileBuffer, mimetype } = emoji;

			const isUploadable = await Media.isImage(fileBuffer);
			if (!isUploadable) {
				throw new Meteor.Error('emoji-is-not-image', "Emoji file provided cannot be uploaded since it's not an image");
			}

			const [, extension] = mimetype.split('/');
			fields.extension = extension;

			const emojiData = await insertOrUpdateEmoji(this.userId, {
				...fields,
				newFile: true,
				aliases: fields.aliases || '',
				name: fields.name,
				extension: fields.extension,
			});

			await uploadEmojiCustomWithBuffer(this.userId, fileBuffer, mimetype, emojiData);

			return API.v1.success();
		},
	)

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Upload a real raster image (PNG/JPEG/GIF/WebP).
  2. Pre-validate client-side via file.type and/or magic-byte detection before POSTing.
  3. Re-export the source asset as a standard image format.

Example fix

// before
const fd = new FormData(); fd.append('emoji', file, file.name); // file may be a .svg
// after
const allowed = ['image/png','image/jpeg','image/gif','image/webp'];
if (!allowed.includes(file.type)) throw new Error('please choose a PNG/JPEG/GIF/WebP image');
const fd = new FormData(); fd.append('emoji', file, file.name);
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['image/png','image/jpeg','image/gif','image/webp'];
if (!ALLOWED.includes(file.type)) throw new Error('emoji must be an image');

Type guard

function isImageFile(f): f is File {
  return f instanceof File && f.type.startsWith('image/');
}

Try / catch

try { await createEmojiCustom(fd); }
catch (e) {
  if (isApiError(e, 'emoji-is-not-image')) { /* prompt user for a real image */) }
  else throw e;
}

Prevention

When it happens

Trigger: Uploading a text/PDF/JSON file renamed to .png; a corrupted or truncated image; a format Media.isImage does not accept; an empty buffer.

Common situations: Wrong file selected in the picker; asset exported as SVG with embedded non-image data; client skips preview validation; file truncated during upload.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/d0c88ef6ea944e40. Report an issue: GitHub.