fix(detectors): report Omnisend verifier errors#5031
Conversation
| switch res.StatusCode { | ||
| case http.StatusUnauthorized, http.StatusForbidden: | ||
| return false, nil | ||
| default: | ||
| if res.StatusCode >= 200 && res.StatusCode < 300 { | ||
| return true, nil | ||
| } | ||
| return false, fmt.Errorf("unexpected HTTP response status %d", res.StatusCode) | ||
| } |
There was a problem hiding this comment.
It'd be better to test the actual api with real credentials and observe the API behavior and then adjust these cases accordingly, instead of setting generic ranges/codes.
There was a problem hiding this comment.
I narrowed this to endpoint-specific status handling instead of accepting any 2xx response. The verifier now only treats 200 OK as verified, keeps 401/403 as unverified, and reports other statuses as verification errors.
I do not have valid Omnisend credentials to confirm a successful account response. I did verify the live endpoint with an invalid key and without the header; both returned 403 {"error":"Forbidden"}. The Omnisend v3 List contacts docs list 200, 401, 403, 408, 422, and 429 for this endpoint, so I added a regression test to ensure 201 Created is no longer treated as verified.
c9a94da to
0cb2345
Compare
Description:
Related to #4051. This updates the Omnisend detector verifier to report indeterminate verification failures instead of silently ignoring them.
Before this change, Omnisend verification only marked 2xx responses as verified. Network/client errors and unexpected API statuses were dropped, which made verifier failures indistinguishable from determinately invalid credentials.
This PR keeps behavior narrow:
VerificationError.Local validation:
gofmt -w pkg/detectors/omnisend/omnisend.go pkg/detectors/omnisend/omnisend_test.gogit diff --checkgo test -count=1 ./pkg/detectors/omnisendgo test -count=1 ./pkg/detectorsgo vet ./pkg/detectors/omnisendgo run ./hack/checksecretparts -fail ./pkg/detectorsgo test -timeout=5m -count=1 ./pkg/detectors/...Checklist:
go testcommands listed above)go vet,git diff --check,checksecretpartslisted above)Note
Low Risk
Scoped to Omnisend detector verification behavior and tests; no auth or core engine changes, with a slight tightening from any 2xx to 200-only for verified.
Overview
Refactors the Omnisend detector verifier so indeterminate failures are visible instead of being dropped silently.
Verification moves into
verifyMatchwith an injectablehttp.ClientonScanner(defaulting to the shared sane client). 200 OK marks the key verified; 401/403 stay unverified with no verification error; request failures and other HTTP statuses setVerificationError. Response bodies are drained and closed after the contacts API call.Adds unit tests that mock the transport to assert the verification URL/header and cover success, auth failures, network errors, and unexpected status codes.
Reviewed by Cursor Bugbot for commit 0cb2345. Bugbot is set up for automated code reviews on this repo. Configure here.