{"thread":{"id":"63091","subject":"[GSoC PATCH v2 0/1] improve smtp auth error handling logic","startedAt":"2025-03-11T06:25:01Z","lastAt":"2025-03-11T06:49:34Z","messageCount":3,"participants":["Zheng Yuting","Yuting Zheng"],"isPatch":true,"patchVersion":2,"patchTotal":1},"messages":[{"id":"513969","messageId":"20250311062440.3566116-1-05ZYT30@gmail.com","threadId":"63091","inReplyTo":null,"subject":"[GSoC PATCH v2 0/1] improve smtp auth error handling logic","fromName":"Zheng Yuting","fromEmail":"05zyt30@gmail.com","sentAt":"2025-03-11T06:24:12Z","receivedAt":"2025-03-11T06:25:01Z","isPatch":true,"sender":{"key":"05zyt30@gmail.com","avatar":"https://avatars.githubusercontent.com/u/87643662?v=4"},"body":"This patch enhances error handling in the smtp_auth_maybe() function by\ndistinguishing between temporary errors and permanent authentication\nfailures.\n\nZheng Yuting (1):\n  improve smtp authentication error handling logic\n\n git-send-email.perl | 30 ++++++++++++++++++++++--------\n 1 file changed, 22 insertions(+), 8 deletions(-)\n\n--\n2.49.0.rc0.57.gdb91954e18\n"},{"id":"513970","messageId":"20250311062440.3566116-2-05ZYT30@gmail.com","threadId":"63091","inReplyTo":"20250311062440.3566116-1-05ZYT30@gmail.com","subject":"[GSoC PATCH v2 1/1] improve smtp authentication error handling logic","fromName":"Zheng Yuting","fromEmail":"05zyt30@gmail.com","sentAt":"2025-03-11T06:24:13Z","receivedAt":"2025-03-11T06:25:05Z","isPatch":true,"sender":{"key":"05zyt30@gmail.com","avatar":"https://avatars.githubusercontent.com/u/87643662?v=4"},"body":"---\n git-send-email.perl | 30 ++++++++++++++++++++++--------\n 1 file changed, 22 insertions(+), 8 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 798d59b84f..a012d61abb 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1419,19 +1419,19 @@ sub smtp_auth_maybe {\n \t\tdie \"invalid smtp auth: '${smtp_auth}'\";\n \t}\n\n-\t# TODO: Authentication may fail not because credentials were\n+\t# Authentication may fail not because credentials were\n \t# invalid but due to other reasons, in which we should not\n \t# reject credentials.\n \t$auth = Git::credential({\n \t\t'protocol' => 'smtp',\n \t\t'host' => smtp_host_string(),\n \t\t'username' => $smtp_authuser,\n-\t\t# if there's no password, \"git credential fill\" will\n-\t\t# give us one, otherwise it'll just pass this one.\n \t\t'password' => $smtp_authpass\n+\n \t}, sub {\n \t\tmy $cred = shift;\n-\n+\t\tmy $result;\n+\t\tmy $error;\n \t\tif ($smtp_auth) {\n \t\t\tmy $sasl = Authen::SASL->new(\n \t\t\t\tmechanism => $smtp_auth,\n@@ -1441,13 +1441,27 @@ sub smtp_auth_maybe {\n \t\t\t\t\tauthname => $cred->{'username'},\n \t\t\t\t}\n \t\t\t);\n-\n \t\t\treturn !!$smtp->auth($sasl);\n+\t\t} else {\n+\t\t\t# Handle plain authentication errors\n+\t\t\teval {\n+\t\t\t\t$result = $smtp->auth($cred->{'username'}, $cred->{'password'});\n+\t\t\t\t1; # Ensure true value is returned\n+\t\t\t} or do {\n+\t\t\t\t$error = $@ || 'Unknown error';\n+\t\t\t};\n \t\t}\n-\n-\t\treturn !!$smtp->auth($cred->{'username'}, $cred->{'password'});\n+\t\t# Unified error handling logic\n+\t\tif ($error) {\n+\t\t\t# Match temporary errors\n+\t\t\tif ($error =~ /timeout|temporary|greylist|throttled|quota\\s+exceeded|queue|overload|try\\s+again|connection\\s+lost|network\\s+error/i) {\n+\t\t\t\twarn \"SMTP temporary error: $error\";\n+\t\t\t\treturn 1;\n+\t\t\t}\n+\t\t\treturn 0;\n+\t\t}\n+\t\treturn !!$result;\n \t});\n-\n \treturn $auth;\n }\n\n--\n2.49.0.rc0.57.gdb91954e18\n"},{"id":"513971","messageId":"CAMvj1+r4K4ppX4GC_-1R5TjfhGcGGH6ccT5V51w-QS8nS+LZwA@mail.gmail.com","threadId":"63091","inReplyTo":"20250311062440.3566116-2-05ZYT30@gmail.com","subject":"Re: [GSoC PATCH v2 1/1] improve smtp authentication error handling logic","fromName":"Yuting Zheng","fromEmail":"05zyt30@gmail.com","sentAt":"2025-03-11T06:49:23Z","receivedAt":"2025-03-11T06:49:34Z","isPatch":true,"sender":{"key":"05zyt30@gmail.com","avatar":"https://avatars.githubusercontent.com/u/87643662?v=4"},"body":"Hi everyone,\n\nI am a new contributor; please forgive my mistake.\nI mistakenly released the v2 patch without any code changes.\nPlease disregard this version and avoid reverting based on it.\nI will release a corrected patch with the intended updates shortly.\n\nApologies for any inconvenience.\n\nBest regards,\nZheng Yuting\n\nOn Tue, Mar 11, 2025 at 2:25 PM Zheng Yuting <05zyt30@gmail.com> wrote:\n>\n> ---\n>  git-send-email.perl | 30 ++++++++++++++++++++++--------\n>  1 file changed, 22 insertions(+), 8 deletions(-)\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 798d59b84f..a012d61abb 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1419,19 +1419,19 @@ sub smtp_auth_maybe {\n>                 die \"invalid smtp auth: '${smtp_auth}'\";\n>         }\n>\n> -       # TODO: Authentication may fail not because credentials were\n> +       # Authentication may fail not because credentials were\n>         # invalid but due to other reasons, in which we should not\n>         # reject credentials.\n>         $auth = Git::credential({\n>                 'protocol' => 'smtp',\n>                 'host' => smtp_host_string(),\n>                 'username' => $smtp_authuser,\n> -               # if there's no password, \"git credential fill\" will\n> -               # give us one, otherwise it'll just pass this one.\n>                 'password' => $smtp_authpass\n> +\n>         }, sub {\n>                 my $cred = shift;\n> -\n> +               my $result;\n> +               my $error;\n>                 if ($smtp_auth) {\n>                         my $sasl = Authen::SASL->new(\n>                                 mechanism => $smtp_auth,\n> @@ -1441,13 +1441,27 @@ sub smtp_auth_maybe {\n>                                         authname => $cred->{'username'},\n>                                 }\n>                         );\n> -\n>                         return !!$smtp->auth($sasl);\n> +               } else {\n> +                       # Handle plain authentication errors\n> +                       eval {\n> +                               $result = $smtp->auth($cred->{'username'}, $cred->{'password'});\n> +                               1; # Ensure true value is returned\n> +                       } or do {\n> +                               $error = $@ || 'Unknown error';\n> +                       };\n>                 }\n> -\n> -               return !!$smtp->auth($cred->{'username'}, $cred->{'password'});\n> +               # Unified error handling logic\n> +               if ($error) {\n> +                       # Match temporary errors\n> +                       if ($error =~ /timeout|temporary|greylist|throttled|quota\\s+exceeded|queue|overload|try\\s+again|connection\\s+lost|network\\s+error/i) {\n> +                               warn \"SMTP temporary error: $error\";\n> +                               return 1;\n> +                       }\n> +                       return 0;\n> +               }\n> +               return !!$result;\n>         });\n> -\n>         return $auth;\n>  }\n>\n> --\n> 2.49.0.rc0.57.gdb91954e18\n"}]}