{"record":{"id":"0243276df05b5331","repo":"Foundry376/Mailspring","slug":"message-messageid-has-no-attachment-with-id","errorCode":null,"errorMessage":"Message '${messageId}' has no attachment with id '${fileId}'","messagePattern":"Message '(.+?)' has no attachment with id '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/internal_packages/mcp-server/lib/mcp-tools.ts","lineNumber":359,"sourceCode":"          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          ],\n        };\n      } catch (err) {\n        audit(`error: ${(err as Error).message}`.slice(0, 100));\n        throw err;","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/internal_packages/mcp-server/lib/mcp-tools.ts#L341-L377","documentation":"Resource handler guard in registerResources: the message was found and allowed, but no file in message.files has an id matching the fileId segment of the resource URI. The attachment reference is stale or mistyped; the attachment may have been removed from the message.","triggerScenarios":"Thrown at app/internal_packages/mcp-server/lib/mcp-tools.ts:359 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-read the message's files list (e.g. via a messages tool) and use the current attachment id","Ensure percent-encoding of the file id matches what the resource list emitted"],"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"}