{"record":{"id":"05f42f2ff23da0b5","repo":"Foundry376/Mailspring","slug":"cannot-find-thread-message-threadid-to-process","errorCode":null,"errorMessage":"Cannot find thread ${message.threadId} to process mail rules.","messagePattern":"Cannot find thread (.+?) to process mail rules\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/mail-rules-processor.ts","lineNumber":190,"sourceCode":"        const allMatching = messages.filter((message) => this._checkRuleForMessage(rule, message));\n\n        // Rules are declared at the message level, but actions are applied to\n        // threads. To ensure we don't apply the same action 50x on the same thread,\n        // just process one match per thread.\n        const seenThreadIds = new Set<string>();\n        const matching = [];\n        for (const message of allMatching) {\n          if (!seenThreadIds.has(message.threadId)) {\n            seenThreadIds.add(message.threadId);\n            matching.push(message);\n          }\n        }\n        for (const message of matching) {\n          // We always pull the thread from the database, even though it may be in\n          // `incoming.thread`, because rules may be modifying it as they run!\n          const thread = await DatabaseStore.find<Thread>(Thread, message.threadId);\n          if (!thread) {\n            console.warn(`Cannot find thread ${message.threadId} to process mail rules.`);\n            continue;\n          }\n          await this._applyRuleToMessage(rule, message, thread);\n        }\n      } catch (err) {\n        // Errors during condition evaluation (e.g. invalid regex) should disable\n        // the rule rather than crash the entire processor and block other rules.\n        Actions.disableMailRule(rule.id, err.toString());\n      }\n    }\n  }\n\n  _conditionTemplateMap: Map<string, (typeof ConditionTemplates)[number]> | null = null;\n\n  _getConditionTemplateMap() {\n    if (!this._conditionTemplateMap) {\n      this._conditionTemplateMap = new Map();\n      for (const t of ConditionTemplates) {","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/mail-rules-processor.ts#L172-L208","documentation":"processMessages could not load the Thread for a message's threadId before applying rule actions, which operate on threads. Fires when the message is a draft/outbox-only message, the thread was deleted, or the database read raced with a sync deletion.","triggerScenarios":"Thrown at app/src/mail-rules-processor.ts:190 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ignore if the thread was deleted concurrently; the rule will apply to remaining messages","Re-run mail rules after sync completes so threads are loaded","Check for messages without valid thread associations (e.g. pending drafts)"],"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"}