Skip to content

[BUGFIX] clickhouse: only skip FORMAT JSON for a trailing FORMAT clause and surface query errors - #867

Open
Yash121l wants to merge 1 commit into
perses:mainfrom
Yash121l:fix/clickhouse-query-format
Open

Yash121l wants to merge 1 commit into
perses:mainfrom
Yash121l:fix/clickhouse-query-format

Conversation

@Yash121l

Copy link
Copy Markdown
Contributor

Description

Fixes #842

Two problems in the ClickHouse client made panels fail without saying why.

  • The client skipped appending FORMAT JSON whenever "format" appeared anywhere in the query, so a column, alias or string literal named format made ClickHouse answer in its default TSV and the JSON parse failed. It now skips the append only when the query ends with a FORMAT <name> clause (case-insensitive, optional trailing ;), and not when the last words are format ASC or format DESC from an ORDER BY. FORMAT is the last clause of a ClickHouse SELECT, so the end of the query is the only place a real one can be.
  • A non-ok response was logged to the console and returned as { status: 'error', data: [] }. Neither caller reads status, so a syntax or permission error showed as "No data". The client now throws with the HTTP status and the ClickHouse message, the same way the Loki and Splunk clients do, and the panel shows the error.

I left the body.data || body fallback from the issue alone. #844's row normalisation already handles a non-array data on the series path, and changing it here would touch the logs path too.

New unit tests in click-house-client.test.ts use a stubbed fetch: five query shapes for the FORMAT check and a 400 response that must reject with the ClickHouse message. They failed before the change. npm run test, lint and type-check for the clickhouse workspace and npm run format:check pass.

Screenshots

None, no UI changes.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

…se and surface query errors

Signed-off-by: Yash Lunawat <yash.lunawat@rtp.vc>
@Yash121l
Yash121l requested a review from a team as a code owner October 11, 2026 15:35
@Yash121l
Yash121l requested review from jgbernalp and removed request for a team October 11, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] clickhouse: FORMAT substring check, envelope fallback and swallowed errors

1 participant