Skip to content

Remove curl usages - #108296

Merged
alexey-milovidov merged 14 commits into
masterfrom
remove-curl-usages
Jun 24, 2026
Merged

alexey-milovidov merged 14 commits into
masterfrom
remove-curl-usages

Conversation

@thevar1able

@thevar1able thevar1able commented Jun 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Remove usages of curl library across codebase and contribs.

Version info

  • Merged into: 26.6.1.1191

thevar1able and others added 5 commits June 11, 2026 16:08
The HTTP transport of `google_cloud_cpp_rest_internal` is now implemented
on `Poco::Net` (`contrib/google-cloud-cpp-cmake/poco_rest_client.cc`),
replacing the libcurl-based one. The libcurl implementation sources are
excluded from the build and `CURL::libcurl` is no longer linked; curl
headers remain include-only for declarations referenced by legacy
`storage::oauth2` template default parameters that are never instantiated.

The submodule is updated to replace `CurlHandle::MakeEscapedString` in
signed URL canonicalization with a curl-free strict RFC 3986 encoder
matching `curl_easy_escape` semantics.

An empty header value means "do not send the header", matching the
libcurl transport where an empty value unsets a header: the storage stub
relies on this to disable chunked transfer encoding, and a literal empty
`Transfer-Encoding` header makes servers ignore `Content-Length`.

Verified end-to-end against fake-gcs-server: resumable upload, metadata
parsing, and streaming download work through the new transport, and the
resulting libraries contain no references to curl symbols.

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
@thevar1able

thevar1able commented Jun 23, 2026 •

Copy link
Copy Markdown
Member Author

Supersedes #108254

@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [49061c5]

Summary: ❌

job_name test_name status info comment
Stress test (arm_tsan) FAIL
Logical error: Block structure mismatch in A stream: different columns: (STID: 0993-28b7) FAIL cidb, issue
AST fuzzer (arm_asan_ubsan) FAIL
Logical error: Block structure mismatch in A stream: different columns: (STID: 0993-27f0) FAIL cidb, issue

AI Review

Summary

This PR removes the vendored curl dependency and replaces the affected SDK transports with Poco-based implementations for Google Cloud REST, librdkafka OIDC HTTP, and Azure SDK internal token requests. Several earlier transport-contract gaps have been addressed in the current head, but the GCS REST replacement still changes proxy semantics and disables the documented pooled-client path, so I would not approve it yet.

Findings

⚠️ Majors

  • [contrib/google-cloud-cpp-cmake/poco_rest_client.cc:173] ProxyOption promises a full {scheme}://host[:port] proxy URI and defaults the scheme to https, while the old curl transport passed that full URI to CURLOPT_PROXY. This replacement only maps the scheme to a default port and then calls session->setProxy(host, port), which uses a plain HTTP proxy connection. A default ProxyConfig().set_hostname("proxy") therefore changes from an HTTPS proxy to a non-TLS proxy connection on port 443, breaking configured GCS proxies and potentially sending proxy credentials over the wrong transport. Preserve the proxy scheme semantics with a transport that supports HTTPS proxies, or reject unsupported proxy schemes explicitly instead of silently connecting differently.
  • [contrib/google-cloud-cpp-cmake/poco_rest_client.cc:516] MakePooledRestClient is the GCS REST stub path that honors ConnectionPoolSizeOption, but it now returns the unpooled client and creates a new TCP/TLS session for every request. That makes a documented storage option ineffective and is a likely throughput/latency regression for repeated object reads, uploads, and metadata calls. Preserve connection reuse with a Poco-backed pool, or remove/reject the pooling option for this transport with a clear compatibility story and performance evidence.
Tests
  • ⚠️ Add a focused GCS REST transport test covering ProxyOption with the default https scheme and proxy credentials, or otherwise prove unsupported schemes are rejected before any request is sent.
  • ⚠️ Add a focused test or benchmark showing the behavior/performance of repeated GCS requests through MakePooledRestClient, especially when ConnectionPoolSizeOption is set.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: preserve or explicitly reject HTTPS proxy semantics for GCS REST, and either restore pooled GCS connections or make the ConnectionPoolSizeOption contract explicit with focused evidence.

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement submodule changed At least one submodule changed in this PR. labels Jun 23, 2026
@thevar1able thevar1able reopened this Jun 23, 2026
if (options.has<ProxyOption>()) {
auto const& proxy = options.get<ProxyOption>();
if (!proxy.hostname().empty()) {
Poco::UInt16 port = Poco::Net::HTTPSession::HTTP_PORT;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProxyConfig includes a scheme and defaults it to https, and the old curl path passed the full scheme://host[:port] proxy URL. This replacement ignores proxy.scheme() and defaults an empty port to HTTP_PORT, so ProxyConfig().set_hostname("proxy") changes from an HTTPS proxy to port 80 with no proxy TLS.

Please preserve the configured proxy scheme/default port semantics, or reject unsupported proxy schemes explicitly instead of silently connecting to a different proxy endpoint.

// alive until the payload is consumed.
std::unique_ptr<RestClient> MakePooledRestClient(std::string endpoint_address,
Options options) {
return MakeDefaultRestClient(std::move(endpoint_address),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MakePooledRestClient is the path used by the GCS REST stub, and ConnectionPoolSizeOption is a documented storage client option. Returning the unpooled client here makes that option ineffective and forces every GCS request to create a fresh TCP/TLS session, which is a real throughput/latency regression for repeated object reads, uploads, and metadata operations.

Please either preserve pooling with a Poco-backed pool (for example using the existing ClickHouse HTTP connection pool) or remove/reject the pooling option for this transport with a clear migration story.

thevar1able and others added 4 commits June 23, 2026 21:03
…s set

Address review feedback on the Poco-based replacement for librdkafka's
libcurl HTTP transport: when `https.ca.location` or `https.ca.pem` is
configured, trust only those roots instead of also loading the system
trust store. The libcurl-based transport replaced the default trust roots
rather than extending them, so loading defaults here weakened
certificate-pinning/custom-CA semantics for the OIDC token endpoint
(`sasl.oauthbearer.token.endpoint.url`).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address review feedback on the Poco-based replacement for the
libcurl-based `RestClient` transport, making it faithful to the original
`CurlRestClient`:

- Merge `context.options()` with the client options at the start of every
  request, so per-call options carried by an `OptionsSpan` (stall timeout,
  CA bundle, proxy, etc.) are honored throughout building the URL, session
  and headers.
- Apply `UnifiedCredentialsOption`: map it to an OAuth 2.0 credential in
  the constructor and add the resulting authentication header to each
  request. External-account and impersonated service-account credentials
  build their token-fetching clients via `MakeDefaultRestClient` and were
  previously sent unauthenticated.
- Honor `CurlFollowLocationOption` (defaults to false and is unset in
  ClickHouse) instead of always following redirects, and resolve relative
  `Location` values against the current URL so a `Location: /path`
  redirect keeps the scheme and host.
- When an explicit CA bundle is configured via `CARootsFilePathOption`,
  do not also load the system trust store, preserving custom-CA/pinning
  semantics.
- Default a payload's `Content-Type` to `application/x-www-form-urlencoded`
  and percent-encode the body to match the libcurl transport; the
  `form_data` `Post` overload marks its own `Content-Type` so its
  already-encoded body is not encoded twice.
- Default the proxy port from the configured `ProxyConfig` scheme (443 for
  `https`) instead of always assuming the plain-HTTP port.
- Document that `ConnectionPoolSizeOption` is intentionally ignored because
  `Poco::Net::HTTPClientSession` is not thread-safe.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
return result;
}

std::chrono::seconds RequestTimeout(Options const& options) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransferStallTimeoutOption and DownloadStallTimeoutOption are not plain socket timeouts in the curl transport: curl applies the download timeout to GET, the transfer timeout to uploads/other requests, and aborts when the transfer rate stays below the configured minimum rate for that many seconds. This helper collapses both options into one Poco send/receive timeout, ignores TransferStallMinimumRateOption/DownloadStallMinimumRateOption, and starts from 120s, so a client setting DownloadStallTimeoutOption{5s} still waits 120s for a stalled GET.

Please preserve the method-specific stall contract (including the minimum-rate checks while streaming), or reject unsupported non-default stall-rate options instead of silently making configured GCS read/write stall detection ineffective.

@thevar1able

Copy link
Copy Markdown
Member Author

⚠️ Add a focused GCS REST transport test covering ProxyOption with the default https scheme and proxy credentials, or otherwise prove unsupported schemes are rejected before any request is sent.
⚠️ Add a focused test or benchmark showing the behavior/performance of repeated GCS requests through MakePooledRestClient, especially when ConnectionPoolSizeOption is set.

google-cloud-cpp has no production usages in the codebase, no need for tests/benchmarks here.

@clickhouse-gh

clickhouse-gh Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 10/10 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@thevar1able
thevar1able marked this pull request as ready for review June 24, 2026 00:28
@alexey-milovidov alexey-milovidov self-assigned this Jun 24, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 24, 2026
Merged via the queue into master with commit cd94c0a Jun 24, 2026
167 checks passed
@alexey-milovidov
alexey-milovidov deleted the remove-curl-usages branch June 24, 2026 01:54
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 24, 2026
alexey-milovidov added a commit to SteveBalayanAKAMedian/ClickHouse that referenced this pull request Jul 15, 2026
The pinned pulsar-client-cpp revision predates several changes in the
ClickHouse third-party stack, so the contrib CMake file now provides
compatibility layers instead of requiring changes inside the submodule:

- ClickHouse removed the `curl` submodule (PR ClickHouse#108296), so a minimal stub of
  the libcurl API is provided in `curl-stub/`. The Pulsar binary protocol
  (`pulsar://`) is fully functional; HTTP topic lookup (`http://` service
  URLs) and OAuth2 authentication fail at runtime with a clear error.
  `curl_easy_escape` (used by `TopicName` percent-encoding) is implemented
  for real.
- Boost was updated to 1.90, which removed the deprecated Asio APIs the
  client uses (`io_service`, `const_buffers_1`/`mutable_buffers_1`,
  `resolver::query`/`iterator`, `expires_from_now`, `cancel(error_code &)`,
  `rfc2818_verification`). Shim headers in `asio-compat/` restore them on
  top of the modern API.
- The vendored protobuf returns `absl::string_view` from descriptor
  accessors, so `ProtobufNativeSchema.cc` is compiled from a patched copy
  in `patched/`.
- The protobuf codegen and `Version.h` are now generated into the binary
  directory (the previous version wrote into the submodule working tree and
  relied on a `LIBARARY_DIR` typo that excluded the generated sources from
  the first configure).

Co-Authored-By: Claude Fable 5 <[email protected]>
@rschu1ze rschu1ze mentioned this pull request Aug 17, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Sep 16, 2026
Backport of ClickHouse#114301 (which
targeted 25.8) to 26.6. `curl` is still bundled in 26.6: the removal in
ClickHouse#108296 landed after the
26.6 branch was cut, so it only shipped in 26.7.

Fixes 10 CVEs from the curl 8.21.0 security disclosure that apply to our
build (connection reuse, cookie handling, proxy and Digest auth, mTLS
config matching, WebSocket auto-PONG memory exhaustion).

Adapted for 26.6's reduced source list (see "Disable unused curl
features"): `lib/noproxy.c` was removed upstream, its logic moved into
the new `lib/proxy.c`; also added the new unconditional core files
`lib/cf-recvbuf.c`, `lib/cf-setup.c`, `lib/creds.c`, `lib/peer.c`, and
`lib/vtls/vtls_config.c`.

Verified: every file in the source list compiles, and the resulting
objects have no unresolved internal `Curl_`/`curlx_` symbols.

Co-Authored-By: chethan-64 <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants