Repository navigation
Conversation
Since fd6d880, attemptConnect wraps dial errors as "dialer: %w". wrapClientErr matched *net.OpError with a type switch, so wrapped dial errors fell through to the default case and were reported as permanent "554 5.0.0 Internal server error" instead of "450 4.4.2 Network I/O error". For LMTP this made maddy reject RCPT permanently while the LMTP server was restarting, instead of asking the sender to retry. Look for *net.OpError with errors.As in the default case, so the wrapped error is classified as before while keeping the added context. Fixes foxcpp#872 Signed-off-by: Ahmed Laban <amlaban@outlook.com>
This branch has not been deployed
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.
Fixes #872
Problem
Since fd6d880,
attemptConnectwraps dial errors asfmt.Errorf("dialer: %w", err).wrapClientErrrecognizes network errors with a type switch on*net.OpError, so a wrapped dial error now falls through to thedefaultcase. It is no longer turned into450 4.4.2 Network I/O errorand ends up as a permanent554 5.0.0 Internal server error. With an LMTP target, maddy rejected RCPT permanently while the LMTP server was restarting, instead of asking the sender to retry.Change
defaultcase ofwrapClientErr, look for a*net.OpErrorwitherrors.As.*net.OpErrorhandling into a smallwrapNetErrhelper, used for both the direct and the wrapped case. The returnedSMTPErrorkeeps the full error (including thedialer:context) inErr. The codes and messages are unchanged.Testing
TestConnectRefusedininternal/smtpconn. It dials a closed local port with bothConnectandConnectLMTPand checks for a temporary450 4.4.2SMTPError. It fails ondevwithout the fix (the error comes back asexterrors.fieldsWrap: dialer: dial tcp ...: connection refused) and passes with it.go test ./internal/smtpconn/... ./internal/target/smtp/ ./internal/target/remote/passes.gofmtandgo vet ./internal/smtpconn/are clean.tests/. Locally I used Go 1.25.1 with a temporary modfile (go.mod asks for 1.26), so CI is the check on the real toolchain.