{"record":{"id":"93be2ecdb3aa2d29","repo":"RocketChat/Rocket.Chat","slug":"emoji-not-found","errorCode":null,"errorMessage":"Emoji not found.","messagePattern":"Emoji not found\\.","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/emoji-custom.ts","lineNumber":254,"sourceCode":"\t\tasync function action() {\n\t\t\tconst emoji = await getUploadFormData(\n\t\t\t\t{\n\t\t\t\t\trequest: this.request,\n\t\t\t\t},\n\t\t\t\t{ field: 'emoji', sizeLimit: settings.get('FileUpload_MaxFileSize'), fileOptional: true },\n\t\t\t);\n\n\t\t\tconst { fields, fileBuffer, mimetype } = emoji;\n\n\t\t\tif (!fields._id) {\n\t\t\t\tthrow new Meteor.Error('The required \"_id\" query param is missing.');\n\t\t\t}\n\n\t\t\tconst emojiToUpdate = await EmojiCustom.findOneById<Pick<IEmojiCustom, 'name' | 'extension'>>(fields._id, {\n\t\t\t\tprojection: { name: 1, extension: 1 },\n\t\t\t});\n\t\t\tif (!emojiToUpdate) {\n\t\t\t\tthrow new Meteor.Error('Emoji not found.');\n\t\t\t}\n\n\t\t\tconst emojiData: EmojiData = {\n\t\t\t\tpreviousName: emojiToUpdate.name,\n\t\t\t\tpreviousExtension: emojiToUpdate.extension,\n\t\t\t\taliases: fields.aliases || '',\n\t\t\t\tname: fields.name,\n\t\t\t\textension: fields.extension,\n\t\t\t\t_id: fields._id,\n\t\t\t\tnewFile: false,\n\t\t\t};\n\n\t\t\tconst isNewFile = fileBuffer?.length && !!mimetype;\n\t\t\tif (isNewFile) {\n\t\t\t\temojiData.newFile = isNewFile;\n\t\t\t\tconst isUploadable = await Media.isImage(fileBuffer);\n\t\t\t\tif (!isUploadable) {\n\t\t\t\t\tthrow new Meteor.Error('emoji-is-not-image', \"Emoji file provided cannot be uploaded since it's not an image\");","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/emoji-custom.ts#L236-L272","documentation":"Thrown by POST emoji-custom.update when EmojiCustom.findOneById(fields._id) returns null — no custom emoji exists for that id. Same Meteor.Error construction defect as 395 (message string in the code slot, no structured code). Means the id is wrong or the emoji was deleted between page load and update.","triggerScenarios":"Updating an emoji that another admin deleted; typo in _id; stale id held in the client; _id from a different workspace.","commonSituations":"Two admins managing emojis concurrently; long-open edit form whose target was removed; cache desync.","solutions":["Reload the emoji list and use a current _id.","Handle as a not-found condition and surface a clear message to the user.","If the emoji should exist, verify it was not deleted and check the id spelling."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exists = await EmojiCustom.findOneById(_id);\nif (!exists) { /* reload list; do not call update */ }","typeGuard":"function isExistingEmoji(e): e is { _id: string } { return !!e && typeof e._id === 'string'; }","tryCatchPattern":"try { await updateEmojiCustom(fd); }\ncatch (e) {\n  if (/Emoji not found/i.test(e?.error || '')) { /* reload emoji list and pick a current id */) }\n  else throw e;\n}","preventionTips":["Reload the emoji list after long form idle.","Handle not-found gracefully when multiple admins manage emojis.","Match on the message substring due to the construction defect."],"tags":["emoji-custom","validation","bug","rest-api"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}