fix(pop3): wrap underlying errors#1320
Merged
Merged
Conversation
Three error sites in findAttachmentData drop underlying error context: - gomail.CreateReader error is replaced by a static "not a multipart message" message - mr.NextPart() non-EOF errors are silently swallowed by the loop - the not-found error has no scanned-parts count Wrap the CreateReader error with %w, capture the scan error and surface it as the final error when present, and include the scanned-parts count in the not-found message. Fixes floatpane#688
floatpanebot
previously requested changes
May 21, 2026
Member
floatpanebot
left a comment
There was a problem hiding this comment.
Hi @mvanhorn! Please fix the following issues with your PR:
- Title: Is too long (55 characters). The PR title must be strictly under 40 characters.
Formatting issues have been resolved. Thank you!
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.
What?
findAttachmentDatainbackend/pop3/pop3.gohad three error sites that dropped underlying context:gomail.CreateReaderreturned an error but the wrapping call discarded it with a static"not a multipart message"string.mr.NextPart()loop broke on a non-EOF error without saving it, so the final return at the bottom of the function reported "not found" instead of the real read failure.This PR wraps the
CreateReadererror with%w, captures theNextParterror in a localscanErrand surfaces it as the final error when it is set, and includes the scanned-parts count in the not-found message.Why?
Fixes #688. The reporter noted the missing
%wwrapping at the original line 438. While poking at that site I noticed the silentbreakonmr.NextPart()errors right above it. Those two paths share the same downstream "not found" return, so a multipart parse error in the middle of the stream looks identical to a genuinely missing part. The third change (scanned-parts count) is the smallest possible nudge that makes the two failure modes distinguishable in an error string without changing the return type or call sites.The change is local to
findAttachmentDataand does not touch any caller. Existing tests inbackend/pop3/pop3_test.gostill pass;go build,go vet, andgofmt -lare clean.Fixes #688
AI-assisted.