Foundry376/Mailspring · error
Invalid mailto URI
Error message
Invalid mailto URI
What it means
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.
Source
Thrown at app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts:139
return {
success: false,
error: err instanceof Error ? err.message : 'Unknown error occurred',
};
}
}
/**
* Opens the composer with a pre-filled unsubscribe email for mailto: links.
*
* This allows the user to review the email before sending, as recommended
* for transparency.
*
* @param mailtoUri - The mailto: URI from the List-Unsubscribe header
*/
export function performMailtoUnsubscribe(mailtoUri: string): void {
if (!mailtoUri.toLowerCase().startsWith('mailto:')) {
throw new Error('Invalid mailto URI');
}
// Use the application's openUrl handler which routes to DraftStore._onHandleMailtoLink
// This creates a draft and opens it in the composer for user review
const sanitizedUri = encodeURI(decodeURI(mailtoUri));
require('@electron/remote').getGlobal('application').openUrl(sanitizedUri);
}
/**
* Opens the unsubscribe URL in the user's default browser.
*
* This is used as a fallback when one-click is not available.
*
* @param url - The HTTP/HTTPS URL to open
*/
export function performWebUnsubscribe(url: string): void {
if (!/^https?:\/\/.+/i.test(url)) {
throw new Error('Invalid URL');View on GitHub (pinned to 648c685d60)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts:139 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03).
Data as JSON: /api/errors/3b7ae8c4d74c9098.
Report an issue: GitHub.