Skip to content

Commit

Permalink
bulker: mixpanel: better handle 'failed validation' errors
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Apr 19, 2024
1 parent e19d4ea commit 2af46a5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bulkerlib/implementations/api_based/mixpanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/jitsucom/bulker/jitsubase/utils"
"io"
"net/http"
"strings"
"sync/atomic"
"time"
)
Expand Down Expand Up @@ -88,10 +89,18 @@ func (mp *MixpanelBulker) Upload(reader io.Reader) (int, string, error) {
//get body
var body []byte
body, err = io.ReadAll(res.Body)
if res.StatusCode == 200 || res.StatusCode == 400 {
return res.StatusCode, string(body), nil
strbody := string(body)
statusCode := res.StatusCode
if statusCode == 200 {
return statusCode, strbody, nil
} else if statusCode == 400 {
if strings.Contains(strbody, "some data points in the request failed validation") {
return statusCode, strbody, nil
} else {
return statusCode, "", mp.NewError("status: %v body: %s", statusCode, strbody)
}
} else {
return res.StatusCode, "", mp.NewError("status: %v body: %s err: %v", res.StatusCode, string(body), err)
return statusCode, "", mp.NewError("status: %v body: %s err: %v", statusCode, strbody, err)
}
}

Expand Down

0 comments on commit 2af46a5

Please sign in to comment.