From 0f029fac9caa683fb47034108f9258e3f4b031a5 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 06:39:18 -0400 Subject: [PATCH] fix(fleetreport): anchor upstream-unavailable phrases to the status-code form Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-15370.md | 1 + src/pkg/fleetreport/fleetreport.go | 12 +++++++----- src/pkg/fleetreport/runtime_test.go | 4 ++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changelog.d/fixed-15370.md diff --git a/changelog.d/fixed-15370.md b/changelog.d/fixed-15370.md new file mode 100644 index 0000000000..6e199b2acb --- /dev/null +++ b/changelog.d/fixed-15370.md @@ -0,0 +1 @@ +- Log lines that merely mention "bad gateway", "service unavailable" or "gateway timeout" in prose are no longer classified as GitHub upstream-unavailable errors; only the `: ` forms match (#15370). diff --git a/src/pkg/fleetreport/fleetreport.go b/src/pkg/fleetreport/fleetreport.go index 4158bd87ee..c7b3b5e5ca 100644 --- a/src/pkg/fleetreport/fleetreport.go +++ b/src/pkg/fleetreport/fleetreport.go @@ -825,15 +825,17 @@ func IsGitHubRateLimited(s string) bool { // upstreamUnavailableSubstrings are lower-case fragments that mark a GitHub // gateway-class transient failure (see IsGitHubUpstreamUnavailable). The // status codes are anchored to go-github's " : 503 ..." shape so -// a PR number or page=503 cannot match; 500 is deliberately absent. +// a PR number or page=503 cannot match; 500 is deliberately absent. The +// status phrases are anchored to the same ": " separator so prose that merely +// mentions them does not match. var upstreamUnavailableSubstrings = []string{ ": 502 ", ": 503 ", ": 504 ", - "bad gateway", - "service unavailable", - "gateway timeout", - "gateway time-out", + ": bad gateway", + ": service unavailable", + ": gateway timeout", + ": gateway time-out", } // IsGitHubUpstreamUnavailable reports whether s (a log message or an error diff --git a/src/pkg/fleetreport/runtime_test.go b/src/pkg/fleetreport/runtime_test.go index b46a572bac..cfd85aae66 100644 --- a/src/pkg/fleetreport/runtime_test.go +++ b/src/pkg/fleetreport/runtime_test.go @@ -804,6 +804,10 @@ func TestIsGitHubUpstreamUnavailable(t *testing.T) { {"GET https://api.github.com/repos/o/r/pulls/1336: 503 []", true}, {"GET https://api.github.com/repos/o/r/pulls/1: 504 Gateway Timeout []", true}, {"upstream: Service Unavailable", true}, + {"GET https://api.github.com/repos/o/r: 503 Service Unavailable []", true}, + {"issue title mentions service unavailable but request succeeded", false}, + {`"bad gateway" appears in quoted prose`, false}, + {"gateway timeout handling was documented", false}, {"GET https://api.github.com/repos/o/r: 500 Internal Server Error", false}, {"GET https://api.github.com/repos/o/r: 404 Not Found", false}, {"GET https://api.github.com/repos/o/r/pulls/503: 404 Not Found", false},