Repository navigation
fix(clickhouse-http): escape bound parameters as ClickHouse reads them - #132
Conversation
Scalar HTTP parameters are read in the escaped (TabSeparated) format, so a newline failed to parse and a backslash changed the value. Array parameters are read as literals, where JSON's double-quoted strings do not parse. Escape scalars, and write arrays as ClickHouse literals. Fixes #38 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Maple review🟢 Confidence 10/10 · safe to merge. I exercised the new escaping on adversarial inputs and it round-trips; the live test covers both layers, leaving only the duplicated literal escaping. Rewrites HTTP param serialization in
Findings🔵 Note · F1 · Array elements re-escape ClickHouse strings instead of
|
Fixes #38.
ClickhouseHttpClientsent each parameter asparam_pN=String(value). ClickHouse reads a scalar HTTP parameter in the escaped (TabSeparated) format, so:BAD_QUERY_PARAMETER;a\\nbarrived asa<LF>b, silently changing the data.While reproducing this, I found that array parameters were sent as
JSON.stringify(value). ClickHouse reads an array parameter as a literal, with no TabSeparated layer, and rejects double-quoted strings, so an array of strings did not bind at all (CANNOT_PARSE_QUOTED_STRING). Arrays are now written as ClickHouse literals (['a\\'b', NULL, 1]), and only their quoted strings are escaped. I checked both layers with curl against ClickHouse 26.8.Verification
tests/clickhouse-http.clickhouse.test.tsround-tripsa\nb, a literala\\nb, double backslashes, a tab, CR, NUL andé é 🙂\n|\t\\nas a scalar and inside an array withit's. It fails onmainand passes here (ClickHouse 26.8.2.7).bun run typecheckandbun run test(1430 tests): green.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.