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

loki returns 500 code for parse error in labels #929

Closed
candlerb opened this issue Aug 21, 2019 · 0 comments · Fixed by #975
Closed

loki returns 500 code for parse error in labels #929

candlerb opened this issue Aug 21, 2019 · 0 comments · Fixed by #975
Labels
component/loki good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! type/bug Somehing is not working as expected

Comments

@candlerb
Copy link
Contributor

candlerb commented Aug 21, 2019

Describe the bug
If you provide a POST to /api/prom/push where the "labels" member is unparseable, loki rejects it with a 500 error. IMO it should be 400.

500 implies that (a) the fault is at the server side, not with the client-provided data; and (b) that it may work if the client resends the same request later, which clearly it won't in this case.

(Extracted from #927)

To Reproduce
Steps to reproduce the behavior:

  1. Started loki (v0.3.0)
  2. Submit with curl where "labels" contains an unterminated string - see end

Expected behavior
A 400 "Bad Request" error code (which is the behaviour if the request is invalid for other reasons, e.g. you submit a log timestamp that is too far in the past)

Environment:

  • Ubuntu 18.04
  • Manual build

Screenshots, promtail config, or terminal output

Trimmed request:

# curl -v -H Content-Type:application/json -d '{"streams":[{"labels":"{foo=\"bar}"}]}' http://127.0.0.1:3100/api/prom/push
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3100 (#0)
> POST /api/prom/push HTTP/1.1
> Host: 127.0.0.1:3100
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 38
>
* upload completely sent off: 38 out of 38 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Wed, 21 Aug 2019 10:29:58 GMT
< Content-Length: 53
<
parse error at line 1, col 6: literal not terminated
* Connection #0 to host 127.0.0.1 left intact

A more complete request which showed this:

# curl -v -H Content-Type:application/json -d '{"streams":[{"labels":"{job=\"fluent.info\",source=\"\",facility=\"\",severity=\"\",program=\"\",foo=\"\"\"}","entries":[{"ts":"2019-08-21T09:34:34.733352Z","line":"worker=\"0\" message=\"fluentd worker is now stopping worker=0\""}]}]}' http://127.0.0.1:3100/api/prom/push
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3100 (#0)
> POST /api/prom/push HTTP/1.1
> Host: 127.0.0.1:3100
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 235
>
* upload completely sent off: 235 out of 235 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Wed, 21 Aug 2019 10:24:12 GMT
< Content-Length: 54
<
parse error at line 1, col 71: literal not terminated
* Connection #0 to host 127.0.0.1 left intact
@cyriltovena cyriltovena added component/loki good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! kind/bug labels Aug 30, 2019
@chaudum chaudum added the type/bug Somehing is not working as expected label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/loki good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! type/bug Somehing is not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants