fix(notify,esg): classify dropped SMTP connections, OAuth2 token-endpoint outages and body-read connection loss as transient (NTF-2, ESG-1, WP4 task 4.6)

This commit is contained in:
Joseph Doherty
2026-12-03 09:58:10 -05:00
parent 5f7b850af2
commit 11992075e8
8 changed files with 210 additions and 14 deletions
@@ -396,6 +396,22 @@ public class ExternalSystemClient : IExternalSystemClient
throw ErrorClassifier.AsTransient(
$"Timeout reading response from {system.Name} after {effectiveTimeout.TotalSeconds:0.##}s", ex);
}
catch (Exception ex) when (ex is IOException or HttpRequestException)
{
// ESG-1: headers arrived, then the connection was reset or the body truncated
// (IOException / HttpIOException / HttpRequestException from the stream read).
// Nothing classified it, so a raw IOException escaped into the script and a
// CachedCall buffered nothing. A success or transient status is a transient
// failure — the call never completed. A permanent status stays permanent:
// losing its error body does not make it retryable.
if (response.IsSuccessStatusCode || ErrorClassifier.IsTransient(response.StatusCode))
{
throw ErrorClassifier.AsTransient(
$"Connection lost reading the response from {system.Name}: {ex.Message}", ex);
}
body = $"(response body unreadable: {ex.Message})";
}
if (response.IsSuccessStatusCode)
{