Fix two null-access crashes in onboarding autoconfig and thread-list context menu#2740
Merged
Conversation
… MAILSPRING-CLIENT-18, MAILSPRING-CLIENT-2V) onboarding-helpers: getThunderbirdAutoconfig returns the raw xml2js parse result, which is null when the server responds HTTP 200 with an empty or unparseable XML body. The guard `autoConfig !== false` passed for null, causing `autoConfig.emailProvider` to throw. Changed to a truthy check so both false and null are handled correctly. thread-list-context-menu: DatabaseStore.modelify maps IDs to models but returns undefined for any ID not found in the database (e.g. a thread that was deleted between the right-click and the DB lookup). markAsReadItem and other methods iterated this.threads without null-checking, causing `t.unread` to throw. Added .filter(Boolean) when assigning this.threads so undefined entries are dropped before any method touches them. https://claude.ai/code/session_01JRpspgNR3pz8R2fM8XTZGJ
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two distinct null/undefined crashes surfaced in Sentry for release
1.21.1-ae68e881, together affecting 68 users.Bug 1 —
TryThunderbirdAutoconfig: null autoConfig crashes on.emailProvideraccessSentry issues: MAILSPRING-CLIENT-1G (28 users, Windows) · MAILSPRING-CLIENT-18 (18 users, macOS)
Root cause:
getThunderbirdAutoconfigfetches an XML autoconfig URL and returns the result ofxml2js.parseStringPromise(body). When the remote server responds with HTTP 200 but an empty or structurally degenerate XML body,parseStringPromisereturnsnullrather than throwing. The function therefore returnsnull(notfalse), and the call-site guard:passes for
null—null !== falseistrue— and thenautoConfig.emailProviderthrows:This would only happen for users whose email domain has an autoconfig endpoint that returns a 200 with a malformed/empty XML body (e.g. an nginx default page or blank response served at the well-known URL).
Fix: Replace
autoConfig !== falsewith a plain truthy check so bothfalseandnull(and any other falsy value) are handled:Bug 2 —
ThreadListContextMenu.markAsReadItem: undefined thread crashes on.unreadaccessSentry issue: MAILSPRING-CLIENT-2V (22 users)
Root cause:
menuItemTemplatecallsDatabaseStore.modelify(Thread, this.threadIds).modelifybuilds the result array witharr.map(id => modelsByString[id])— if an ID is not found in the database (thread was deleted between the user right-clicking and the DB lookup resolving), the map returnsundefinedfor that slot.markAsReadItem(and other methods) then iteratesthis.threadswithout null-checking:When
tisundefined, accessingt.unreadthrows:Fix: Filter out undefined entries immediately after
modelifyresolves:This protects all downstream methods (
markAsReadItem,markAsSpamItem,archiveItem, etc.) in one place.Test plan
https://autoconfig.<domain>/mail/config-v1.1.xml— account setup should proceed past autoconfig without crashinghttps://claude.ai/code/session_01JRpspgNR3pz8R2fM8XTZGJ
Generated by Claude Code