{"record":{"id":"2b6fbbc0996edd7f","repo":"Foundry376/Mailspring","slug":"could-not-find-important-label","errorCode":null,"errorMessage":"Could not find `important` label","messagePattern":"Could not find `important` label","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/mail-rules-processor.ts","lineNumber":38,"sourceCode":"let MailRulesStore: typeof import('./flux/stores/mail-rules-store').default = null;\ntype MailRule = import('./flux/stores/mail-rules-store').MailRule;\n\n/**\nNote: At first glance, it seems like these task factory methods should use the\nTaskFactory. Unfortunately, the TaskFactory uses the CategoryStore and other\ninformation about the current view. Maybe after the unified inbox refactor...\n*/\nconst MailRulesActions: {\n  [action: string]: (\n    message: Message,\n    thread: Thread,\n    value: string\n  ) => undefined | Task | Promise<undefined> | Promise<Task>;\n} = {\n  markAsImportant: async (message, thread) => {\n    const important = CategoryStore.getCategoryByRole(thread.accountId, 'important');\n    if (!important) {\n      throw new Error('Could not find `important` label');\n    }\n    return new ChangeLabelsTask({\n      labelsToAdd: [important],\n      labelsToRemove: [],\n      threads: [thread],\n      source: 'Mail Rules',\n    });\n  },\n\n  moveToTrash: async (message, thread) => {\n    const folder = CategoryStore.getTrashCategory(thread.accountId);\n    if (!folder) {\n      throw new Error('Could not find `trash` folder');\n    }\n    return new ChangeFolderTask({\n      folder: folder,\n      threads: [thread],\n      source: 'Mail Rules',","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/mail-rules-processor.ts#L20-L56","documentation":"Mail-rule action guard (markAsImportant): CategoryStore found no label with role 'important' for the thread's account, so a ChangeLabelsTask cannot be built. Happens when the account's folders/labels haven't synced yet (rule runs at startup) or the provider has no important label.","triggerScenarios":"Thrown at app/src/mail-rules-processor.ts:38 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for folder/label sync to complete before rules run, or retry the rule once categories are cached","Disable the markAsImportant rule action for account types that don't support labels (e.g. IMAP without an important label)","Ensure the account's important label exists server-side so it syncs down"],"exampleFix":null,"handlingStrategy":"try-catch","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"}