Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change server error response, no appended string to avoid malformed j… #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions feedapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package feedapi
import (
"encoding/json"
"fmt"
"github.com/sirupsen/logrus"
"net/http"
"net/url"
"strconv"
"strings"

"github.com/sirupsen/logrus"
)

// EventPublisher is a generic-based interface that has to be implemented on a server side.
Expand Down Expand Up @@ -125,7 +126,7 @@ func (h HTTPHandlers) EventsHandler(writer http.ResponseWriter, request *http.Re
if err != nil {
logger.WithField("publisherName", h.eventPublisher.GetName()).
WithField("event", "feedapi.server.fetch_events_error").WithError(err).Info()
http.Error(writer, "Internal server error", http.StatusInternalServerError)
writer.WriteHeader(http.StatusInternalServerError)
return
}
}
Expand Down
5 changes: 3 additions & 2 deletions feedapi/v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package feedapi

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestAPI_V2_HappyDay_Smoketest(t *testing.T) {
Expand Down Expand Up @@ -100,7 +101,7 @@ func TestEventsEndpoint(t *testing.T) {
token: "the-token",
partitionID: 0,
cursor: "qwerty",
expectedErrorString: "response code 500, response body: Internal server error\n",
expectedErrorString: "response code 500, empty response body",
},
{
name: "out of range cursor",
Expand Down