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

internal/http_api: fixed error messages quoting #1132

Merged
merged 1 commit into from
Jan 29, 2019
Merged

internal/http_api: fixed error messages quoting #1132

merged 1 commit into from
Jan 29, 2019

Conversation

FilWisher
Copy link
Contributor

Error messages that get bubbled up are returned from the API wrapped
using a call to fmt.Sprintf({"message":"%s"}, data). Double quotes
appearing inside data are unescaped causing incorrectly formatted JSON
(which breaks the UI).

@FilWisher
Copy link
Contributor Author

The API request to /api/topics failed but the JSON response is also incorrectly formatted causing a UI error. The offending error message is:

{"message":"UPSTREAM_ERROR: Failed to query any nsqlookupd: Get http://127.0.0.1:4160/topics: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x00\x0eE_BAD_PROTOCOL""}

You can see the double quotes around \x00\x00..._BAD_PROTOCOL aren't escaped correctly.

@jehiah jehiah added the bug label Jan 28, 2019
Copy link
Member

@jehiah jehiah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this issue!

internal/http_api/api_response.go Outdated Show resolved Hide resolved
@mreiferson
Copy link
Member

I wonder if this explains #727 ???

@ploxiln
Copy link
Member

ploxiln commented Jan 28, 2019

Thanks for the update. There's just one tiny bit which go is not happy with:

internal/http_api/api_response.go:8:2: imported and not used: "strconv"

Error messages that get bubbled up are returned from the API wrapped
using a call to fmt.Sprintf(`{"message":"%s"}`, data). Double quotes
appearing inside `data` are unescaped causing incorrectly formatted JSON
(which breaks the UI).
@ploxiln ploxiln merged commit 21074c4 into nsqio:master Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants