{"record":{"id":"2451bf25b2dfaa4a","repo":"Foundry376/Mailspring","slug":"message-messageid-not-found","errorCode":null,"errorMessage":"Message '${messageId}' not found","messagePattern":"Message '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/internal_packages/mcp-server/lib/mcp-tools.ts","lineNumber":355,"sourceCode":"      const start = Date.now();\n      const audit = (resultSummary: string) =>\n        addAuditEntry({\n          timestamp: Date.now(),\n          toolName: 'resources/read',\n          params: uri.href.slice(0, 200),\n          resultSummary,\n          durationMs: Date.now() - start,\n        });\n\n      try {\n        // Variables come from the SDK's template match on the raw URI, so\n        // they preserve the ids' case (unlike uri.host, which URL lowercases).\n        const messageId = decodeURIComponent(String(variables.messageId));\n        const fileId = decodeURIComponent(String(variables.fileId));\n\n        const message = await DatabaseStore.find<Message>(Message, messageId);\n        if (!message || !isMessageAllowed(message)) {\n          throw new Error(`Message '${messageId}' not found`);\n        }\n        const file = (message.files || []).find((f) => f.id === fileId);\n        if (!file) {\n          throw new Error(`Message '${messageId}' has no attachment with id '${fileId}'`);\n        }\n        const filePath = await attachmentPathOnDisk(file);\n        if (!filePath) {\n          throw new Error(\n            `Attachment '${file.displayName()}' has not been downloaded — call the get_attachment tool first.`\n          );\n        }\n\n        const buffer = await fs.promises.readFile(filePath);\n        audit('ok');\n        return {\n          contents: [\n            { uri: uri.href, mimeType: mimeTypeForFile(file), blob: buffer.toString('base64') },\n          ],","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/internal_packages/mcp-server/lib/mcp-tools.ts#L337-L373","documentation":"Resource handler guard in the MCP server's registerResources: the message id decoded from a mailspring://message/{messageId}/attachment/{fileId} resource URI either does not exist in the local database or belongs to a message the MCP client is not allowed to read. Used to reject unauthorized or stale resource reads.","triggerScenarios":"Thrown at app/internal_packages/mcp-server/lib/mcp-tools.ts:355 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Have the client re-list resources to obtain fresh ids after the database syncs","Verify the message id is URL-encoded correctly when constructing the resource URI"],"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"}