diff --git a/checker/server.go b/checker/server.go index 1036e99..6065fbd 100644 --- a/checker/server.go +++ b/checker/server.go @@ -114,7 +114,7 @@ func (s *Server) handleCollect(w http.ResponseWriter, r *http.Request) { data, err := s.provider.Collect(r.Context(), req.Options) if err != nil { - writeJSON(w, http.StatusOK, ExternalCollectResponse{ + writeJSON(w, http.StatusInternalServerError, ExternalCollectResponse{ Error: err.Error(), }) return @@ -122,7 +122,7 @@ func (s *Server) handleCollect(w http.ResponseWriter, r *http.Request) { raw, err := json.Marshal(data) if err != nil { - writeJSON(w, http.StatusOK, ExternalCollectResponse{ + writeJSON(w, http.StatusInternalServerError, ExternalCollectResponse{ Error: fmt.Sprintf("failed to marshal result: %v", err), }) return diff --git a/checker/server_test.go b/checker/server_test.go index 5802532..3bc36bd 100644 --- a/checker/server_test.go +++ b/checker/server_test.go @@ -143,8 +143,8 @@ func TestServer_Collect_ProviderError(t *testing.T) { } srv := newTestServer(p) rec := doRequest(srv.Handler(), "POST", "/collect", ExternalCollectRequest{Key: "test"}, nil) - if rec.Code != http.StatusOK { - t.Fatalf("POST /collect = %d, want %d", rec.Code, http.StatusOK) + if rec.Code != http.StatusInternalServerError { + t.Fatalf("POST /collect = %d, want %d", rec.Code, http.StatusInternalServerError) } var resp ExternalCollectResponse json.NewDecoder(rec.Body).Decode(&resp)