docs: InsertQueryPlacement.Url is limited to 128 KiB of encoded statement (http_max_field_value_size), not 1 MiB
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- documentation
Research direction
Update the three cited locations: docs/http.mdx and the XML docs in ClickHouse.Driver/InsertOptions.cs and ClickHouse.Driver/InsertQueryPlacement.cs. Read the existing QueryPlacement guidance and confirm the documented URL parameter limit against the evidence in this issue. Done when all three explain the 128 KiB encoded value limit and distinguish it from the 1 MiB whole URI limit; consider noting the URL limit for PostStreamAsync and InsertRawStreamAsync.
Written by the indexing model from the issue text.
Description
Describe the bug
The docs for InsertOptions.QueryPlacement = InsertQueryPlacement.Url name http_max_uri_size (1 MiB) as the server limit for a statement in the URL. The server applies a lower limit first: http_max_field_value_size (128 KiB by default) for each URL query-string value, and the query parameter is one of these values.
On .NET 10 the .NET runtime does not limit the URI. Thus an INSERT statement with more than 131,072 bytes of URL-encoded text fails with HTML Form Exception: Field value too long, although the URI is far below 1 MiB. On .NET 6 through .NET 9, the documented runtime limit of 65,519 characters is correct and lower, so the driver's InvalidOperationException fires first there.
The docs say "the effective limit is the lowest imposed by the .NET runtime, an intermediary and the server", but the server limit that they give is not the lowest one.
PostStreamAsync and InsertRawStreamAsync always send the SQL in the URL, so the same limit applies to them (verified for PostStreamAsync below). The docs do not state a limit for them.
Steps to reproduce
- On
net10.0, create a table whose column list makes theINSERT INTO ... FORMAT RowBinarystatement longer than 128 KiB when URL-encoded (below: 700 columns with 200-character names). - Call
InsertBinaryAsyncwithnew InsertOptions { QueryPlacement = InsertQueryPlacement.Url }. - The insert fails with
HTML Form Exception: Field value too long. The same insert withInsertQueryPlacement.Bodysucceeds.
Expected behaviour
The docs name the limit that the server applies first. Server defaults:
SELECT name, value FROM system.settings WHERE name IN ('http_max_field_value_size','http_max_uri_size','max_query_size')
max_query_size 262144
http_max_uri_size 1048576
http_max_field_value_size 131072
Raw HTTP requests with no client, POST /?query=SELECT+length(%27aaa…%27). The length is that of the encoded query value:
encoded value 131072 bytes -> HTTP/1.1 200 OK
encoded value 131073 bytes -> HTTP/1.1 500 Code: 1000 ... HTML Form Exception: Field value too long
encoded value 131073 bytes + &http_max_field_value_size=1048576 -> HTTP/1.1 500 ... Field value too long
A query-level setting does not raise the limit, because the server parses the URL query string with its default settings. In the server source, HTMLForm::readQuery (src/Server/HTTP/HTMLForm.cpp) throws Field value too long when value.size() reaches max_field_value_size. It checks the raw value before Poco::URI::decode, so the limit applies to the encoded length.
Code example
Reproduction program (C#, 16 lines)
var recorder = new Recorder { InnerHandler = new HttpClientHandler() }; // logs the encoded length of the query= value
using var client = new ClickHouseClient(connectionString, new HttpClient(recorder));
foreach (var (cols, placement) in new[] {
(500, InsertQueryPlacement.Url), (700, InsertQueryPlacement.Url), (700, InsertQueryPlacement.Body) })
{
var table = $"repro_url_limit_{cols}_{placement}".ToLowerInvariant();
var names = Enumerable.Range(0, cols).Select(i => $"c{i:D4}_" + new string('x', 194)).ToArray();
await client.ExecuteNonQueryAsync($"CREATE TABLE {table} ({string.Join(", ", names.Select(n => n + " UInt8"))}) ENGINE = Memory");
var row = names.Select(_ => (object)(byte)1).ToArray();
await client.InsertBinaryAsync(table, names, new[] { row }, new InsertOptions { QueryPlacement = placement });
}
// PostStreamAsync always puts the SQL in the URL
var sql = $"INSERT INTO FUNCTION null('x String') /* {new string('p', 140_000)} */ FORMAT TSV";
await client.PostStreamAsync(sql, new MemoryStream("a\n"u8.ToArray()), false, CancellationToken.None);
Output:
cols=500 placement=Url encodedQueryValue=105051 uri=105303 -> OK, inserted 1, count()=1
cols=700 placement=Url encodedQueryValue=147051 uri=147303 -> ClickHouseServerException: Poco::Exception. Code: 1000, e.code() = 0, HTML Form Exception: Field value too long
cols=700 placement=Body -> OK, inserted 1, count()=1
PostStreamAsync sqlChars=120055 encodedQueryValue=120063 -> 200
PostStreamAsync sqlChars=140055 encodedQueryValue=140063 -> ClickHouseServerException: Poco::Exception. Code: 1000, e.code() = 0, HTML Form Exception: Field value too long
Error log
ClickHouse.Driver.ClickHouseServerException: Poco::Exception. Code: 1000, e.code() = 0, HTML Form Exception: Field value too long
Root cause
The same http_max_uri_size sentence is in three places:
docs/http.mdx:521("Insert query placement"): "ClickHouse'shttp_max_uri_sizeis 1 MiB by default, while an intermediary may impose a lower limit."ClickHouse.Driver/InsertOptions.cs:54(XML doc ofQueryPlacement): "The server'shttp_max_uri_sizeis 1 MiB by default."ClickHouse.Driver/InsertQueryPlacement.cs:19(XML doc ofUrl): "the server'shttp_max_uri_sizeis 1 MiB by default."
The fix is docs only, no code change.
Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Configuration
Environment
- Client version:
main@ c8a72abf (the docs text is there since 1.5.0) - Language version: C# (SDK 10.0.203)
- .NET version: net10.0 (runtime 10.0.14)
- OS: Linux (Docker, Debian-based image)
ClickHouse server
- ClickHouse Server version: 26.9.1.1629
- ClickHouse Server non-default settings, if any: none
CREATE TABLEstatements for tables involved: see code example (ENGINE = Memory, NUInt8columns)- Sample data for all these tables: one row of
1s
Classification: impact: none · area: Docs & project (insert query placement)
Found by automated analysis (Polyglot AI) while working on #700. Verified against a live server.
- Dominant language
- C#
- Stars
- 102
- Forks
- 31
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 40
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/clickhouse-cs
-
bug documentation queries
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/clickhouse-cs#815 ·
Maintainers usually reply within 1 day
-
bug data-types native-format
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-cs#813 ·
Maintainers usually reply within 1 day
-
bug data-types documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cs#811 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cs#809 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/clickhouse-cs#806 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ClickHouse/clickhouse-cs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
XML grammar: only the closing --> of a comment gets the scope comment.block.xmlPossibly taken @alexeyfala claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
danipen/TextMateSharp#145 · 2 comments ·
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Klyroo/klyroo-dashboard#12 ·
Maintainers usually reply within 1 day
-
CONTRIBUTING rules Node out in step 0, then tells client-side contributors to run node --test, which is what CI gates onPossibly taken @yadavraj2001 claimed this today. Opendocumentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
juandresrodca/AdminForge#73 · 1 comment ·
Maintainers usually reply within 1 day
-
[辞書] VIVANTOpen要トリアージ 辞書
Difficulty 1/5 Under an hour Newbie friendliness 70/100
Maintainers usually reply within 1 day