From 2f1c3cd4083504b5b3439acec3a60a60e9878424 Mon Sep 17 00:00:00 2001 From: Arpit Sharma Date: Sat, 7 Oct 2023 16:02:45 +1100 Subject: [PATCH 1/2] fix(collector): exit on 401 when queues specified --- collector/collector.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collector/collector.go b/collector/collector.go index 64c58702..e1065491 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -240,6 +240,10 @@ func (c *Collector) Collect() (*Result, error) { } defer res.Body.Close() + if res.StatusCode == 401 { + return nil, fmt.Errorf("http 401 response received %w", ErrUnauthorized) + } + if c.DebugHttp { if dump, err := httputil.DumpResponse(res, true); err == nil { log.Printf("DEBUG response uri=%s\n%s\n", req.URL, dump) From 24f6bc6b92d0da9332ca87bcb4cdf16b3e439ebf Mon Sep 17 00:00:00 2001 From: Arpit Sharma Date: Sat, 7 Oct 2023 16:13:14 +1100 Subject: [PATCH 2/2] docs(collector): redundant comment --- collector/collector.go | 1 - 1 file changed, 1 deletion(-) diff --git a/collector/collector.go b/collector/collector.go index e1065491..d1a97e35 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -123,7 +123,6 @@ func (c *Collector) Collect() (*Result, error) { res, err := httpClient.Do(req) if err != nil { - // Authorization error signals token is invalid return nil, err } defer res.Body.Close()