{"record":{"id":"f6a3a1a70b4e257f","repo":"Foundry376/Mailspring","slug":"could-not-find-trash-folder","errorCode":null,"errorMessage":"Could not find `trash` folder","messagePattern":"Could not find `trash` folder","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/mail-rules-processor.ts","lineNumber":51,"sourceCode":"  ) => 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',\n    });\n  },\n\n  markAsRead: (message, thread) => {\n    if (thread.unread === false) {\n      return null;\n    }\n    return new ChangeUnreadTask({\n      unread: false,\n      threads: [thread],\n      source: 'Mail Rules',\n    });\n  },","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/mail-rules-processor.ts#L33-L69","documentation":"Mail-rule action guard (moveToTrash): CategoryStore.getTrashCategory returned nothing for the thread's account, so the trash folder to move to is unknown. Typically fires before the folder list has synced or on accounts where no folder has been marked with the trash role.","triggerScenarios":"Thrown at app/src/mail-rules-processor.ts:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the account has a folder mapped to the trash role (set it in account settings/folder mapping)","Retry once folder sync completes at startup"],"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"}