auto-promote large query parameters to form body#789
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the HTTP transport behavior so that very large server-side bind parameters are automatically sent as multipart form fields in the POST body (instead of being URL-encoded into the request URI), reducing the likelihood of HTTP 414 failures from common proxies and load balancers.
Changes:
- Added a shared
use_form_encodingdecision helper (with a URL-length budget) to determine when to auto-promote bind params to form-data. - Updated both sync (
HttpClient) and async clients to use the helper so large bind payloads go through the body while keeping existing behavior for typical queries. - Added unit and integration tests for auto-promotion behavior and updated public docstrings / changelog messaging.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
clickhouse_connect/driver/binding.py |
Introduces the URL-length threshold and use_form_encoding helper used to decide when to route params via form-data. |
clickhouse_connect/driver/httpclient.py |
Switches query/raw_query request construction to use auto form-encoding when bind params are large. |
clickhouse_connect/driver/asyncclient.py |
Mirrors the sync client logic for auto form-encoding in async query and raw_query paths. |
clickhouse_connect/driver/__init__.py |
Updates create_client / create_async_client docstrings to describe the new auto-promotion behavior. |
tests/unit_tests/test_driver/test_httpclient.py |
Adds unit coverage asserting that large bind params are routed into multipart fields even when the flag is off. |
tests/unit_tests/test_driver/test_binding.py |
Adds direct unit coverage for the new use_form_encoding helper (including binary-query behavior). |
tests/integration_tests/test_form_encode_query.py |
Adds integration coverage ensuring large-parameter queries succeed on a default client (sync/async via shared fixtures). |
CHANGELOG.md |
Documents the user-visible behavior change and links it to #740. |
peter-leonov-ch
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
form_encode_query_params=Truestill forces form encoding for all queries.http_max_field_value_sizeand applies to both URL and form transports.Closes #740
Checklist
Delete items not relevant to your PR: