{"record":{"id":"3b7ae8c4d74c9098","repo":"Foundry376/Mailspring","slug":"invalid-mailto-uri","errorCode":null,"errorMessage":"Invalid mailto URI","messagePattern":"Invalid mailto URI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts","lineNumber":139,"sourceCode":"\n    return {\n      success: false,\n      error: err instanceof Error ? err.message : 'Unknown error occurred',\n    };\n  }\n}\n\n/**\n * Opens the composer with a pre-filled unsubscribe email for mailto: links.\n *\n * This allows the user to review the email before sending, as recommended\n * for transparency.\n *\n * @param mailtoUri - The mailto: URI from the List-Unsubscribe header\n */\nexport function performMailtoUnsubscribe(mailtoUri: string): void {\n  if (!mailtoUri.toLowerCase().startsWith('mailto:')) {\n    throw new Error('Invalid mailto URI');\n  }\n\n  // Use the application's openUrl handler which routes to DraftStore._onHandleMailtoLink\n  // This creates a draft and opens it in the composer for user review\n  const sanitizedUri = encodeURI(decodeURI(mailtoUri));\n  require('@electron/remote').getGlobal('application').openUrl(sanitizedUri);\n}\n\n/**\n * Opens the unsubscribe URL in the user's default browser.\n *\n * This is used as a fallback when one-click is not available.\n *\n * @param url - The HTTP/HTTPS URL to open\n */\nexport function performWebUnsubscribe(url: string): void {\n  if (!/^https?:\\/\\/.+/i.test(url)) {\n    throw new Error('Invalid URL');","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts#L121-L157","documentation":"Validation guard at the top of performMailtoUnsubscribe: the value taken from the message's List-Unsubscribe header did not start with 'mailto:' (case-insensitive), so it cannot be opened as a pre-filled unsubscribe draft. Indicates a malformed or unexpected header value, not a runtime failure.","triggerScenarios":"Thrown at app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate/normalize the List-Unsubscribe value before choosing the mailto path","Fall back to performing a web unsubscribe or showing the raw link when the header is malformed","Return a structured {success:false,error} result instead of throwing so callers can degrade gracefully"],"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"}