{"record":{"id":"00a2599e2b24b670","repo":"Foundry376/Mailspring","slug":"the-label-could-not-be-found","errorCode":null,"errorMessage":"The label could not be found.","messagePattern":"The label could not be found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/mail-rules-processor.ts","lineNumber":112,"sourceCode":"    }\n    const folder = CategoryStore.byId(thread.accountId, value);\n    if (!folder || !(folder instanceof Folder)) {\n      throw new Error('The folder could not be found.');\n    }\n    return new ChangeFolderTask({\n      folder: folder,\n      threads: [thread],\n      source: 'Mail Rules',\n    });\n  },\n\n  applyLabel: async (message, thread, value) => {\n    if (!value) {\n      throw new Error('A label is required.');\n    }\n    const label = CategoryStore.byId(thread.accountId, value);\n    if (!label || !(label instanceof Label)) {\n      throw new Error('The label could not be found.');\n    }\n    return new ChangeLabelsTask({\n      labelsToAdd: [label],\n      labelsToRemove: [],\n      threads: [thread],\n      source: 'Mail Rules',\n    });\n  },\n\n  archive: (message, thread) => {\n    const inbox = CategoryStore.getInboxCategory(thread.accountId);\n    if (!inbox) {\n      throw new Error('Could not find `inbox` label');\n    }\n    return new ChangeLabelsTask({\n      labelsToAdd: [],\n      labelsToRemove: [inbox],\n      threads: [thread],","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/mail-rules-processor.ts#L94-L130","documentation":"Lookup failure in the applyLabel action handler: the rule supplies a label id, but CategoryStore.byId returns no category for it, or the returned category is not a Label instance (e.g. it resolves to a Folder/mailbox on IMAP accounts). Fires when the referenced label was deleted or the rule references a category of the wrong kind.","triggerScenarios":"Thrown at app/src/mail-rules-processor.ts:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Edit the rule in Preferences > Mail Rules and re-select an existing label","Recreate the deleted label on the account, or point the rule at another label","Check that the account type actually supports labels (Gmail) rather than folders"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"648c685d602ece6bb00c22534b8734de6ac644b3","analyzedAt":"2026-09-03T02:00:24.311Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}