Skip to content

fix: prevent wrapping nil error on successful SMTP delivery - #169

Merged
andreynering merged 2 commits into
charmbracelet:mainfrom
NiltonVolpato:main
Jun 26, 2026
Merged

andreynering merged 2 commits into
charmbracelet:mainfrom
NiltonVolpato:main

Conversation

@NiltonVolpato

Copy link
Copy Markdown
Contributor

Description

Fixes a regression introduced during a recent refactoring or linting pass where a successful SMTP delivery returns a sending email: %!w(<nil>) error message.

This PR adds an explicit nil check before attempting to annotate the error with context.

Changes

  • Intercept the error returned by the mail delivery client.
  • Return nil immediately if the delivery was successful.
  • Only wrap and return the error with fmt.Errorf if an actual failure occurred.

Verification

  • Verified locally with Google SMTP.
  • Successful emails are sent cleanly without emitting %!w(<nil>) to stderr, and the process exits with status 0.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

The previous code was unconditionally returning an error (regardless of
whether the call had succeeded or not)

@andrinoff andrinoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix looks good

Comment thread email.go Resolved

@andreynering andreynering left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@andreynering
andreynering merged commit abf8ebc into charmbracelet:main Jun 26, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址