-
Notifications
You must be signed in to change notification settings - Fork 5
Description
When querying through Lokxy, if the backend (e.g., Loki) returns an error message instead of a valid JSON response, Lokxy still attempts to parse it as a loghttp.QueryResponse.
This results in misleading parsing errors instead of propagating the real backend error to the client.
Error logs:
{"err":"invalid character 'p' looking for beginning of value","level":"error","msg":"Failed to unmarshal into loghttp.QueryResponse","ts":"2025-09-09T15:51:07.57882597Z"}
{"err":"invalid character 'p' looking for beginning of value","level":"error","msg":"Failed to unmarshal stats response","ts":"2025-09-09T15:51:07.610065822Z"}To Reproduce:
1. Run a Loki query with invalid syntax or unsupported expression (example: {region=~".*"} |= ).
2. Observe that the backend (Loki) returns a plain-text error, such as: parse error : queries require at least one regexp or equality matcher that does not have an empty-compatible value. For instance, app=~".*" does not meet this requirement, but app=~".+" will
3. Lokxy attempts to unmarshal this plain text response as JSON, leading to a invalid character 'p' looking for beginning of value error.
Expected behavior:
Lokxy should:
• Detect when the backend response is not valid JSON.
• Surface the real backend error message back to the client, instead of returning JSON unmarshal errors.
• Possibly (?) wrap it with some context like backend name (e.g., "backend1 error: ").
Below is a screenshot with the difference output between Lokxy (Left) and Loki (right)
