Repository navigation
Respect max_http_get_redirects setting in HTTPDictionarySource - #101768
Conversation
`HTTPDictionarySource` did not call `withRedirects` on its HTTP request builder, causing all redirects to be rejected with `TOO_MANY_REDIRECTS`. Add `.withRedirects(context->getSettingsRef()[Setting::max_http_get_redirects])` to all four request paths (`loadAll`, `loadUpdatedAll`, `loadIds`, `loadKeys`), matching the pattern used in `StorageURL` and other HTTP sources. Fixes ClickHouse#90521
Adds stateless test 04417_http_dictionary_max_redirects, which starts a local HTTP server issuing a 302 redirect and verifies that an HTTP dictionary source follows it only when max_http_get_redirects allows it: it fails with TOO_MANY_REDIRECTS when the setting is 0 and loads the data when redirects are permitted. The dictionary takes max_http_get_redirects from its SETTINGS clause. Closes: ClickHouse#90521
The test number 04417 was taken by other tests merged into master since this branch was created (`04417_client_input_format_from_config`, `04417_docs_web_ui_disclosure_details`, `04417_numeric_indexed_vector_pointwise_multiply_all_ones`). Renumber the HTTP dictionary redirect test to the next free prefix 04498 and update the internal `.python` reference and dictionary names accordingly.
|
Added the requested test and merged current New stateless test
The setting is taken from the dictionary's I validated the behavior locally against a release binary (which lacks this fix): both (The test was numbered |
|
Workflow [PR], commit [5955a89] Summary: ✅
AI ReviewSummaryThis PR makes Findings
Final VerdictStatus: Minimum required actions:
LLVM Coverage ReportMeasured on commit 5955a89.
Changed lines: Changed C/C++ lines covered: 83/91 (91.21%) · Uncovered code |
Enabling `max_http_get_redirects` for HTTP dictionaries without threading `RemoteHostFilter` into the request builders turned the one-time `created_from_ddl` URL check into a bypass: a DDL-created dictionary could point at an allow-listed URL that `302`s to a host outside `remote_url_allow_hosts`, and `ReadWriteBufferFromHTTP` would follow it (and replay the same `Poco::Net::HTTPBasicCredentials` to the redirect target). `StorageURL` pairs `withRedirects` with `withHostFilter` for exactly this reason. Pass `context->getRemoteHostFilter` to the builders in `loadAll`, `loadUpdatedAll`, `loadIds` and `loadKeys` for DDL-created dictionaries, so every hop (including redirects) is validated by `ReadWriteBufferFromHTTP::callImpl`. Config-file dictionaries keep their previous behavior (host filter not applied), matching the existing DDL-only initial-URL check. Adds an integration regression `test_http_dictionary_redirect_remote_host_filter` verifying that a `302` to a host outside `remote_url_allow_hosts` is rejected with `UNACCEPTABLE_URL` and is never actually fetched. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The test starts a local HTTP server and discovers a routable address with `hostname -i`, a Linux-only flag. On macOS (the `arm_darwin` fast test) `hostname` rejects it (`hostname: illegal option -- i`) and the test crashes before reaching the server, so it must be skipped there. Every sibling HTTP-server Python test (`01854_HTTP_dict_decompression`, `02205_HTTP_user_agent`, `02233_HTTP_ranged`, ...) is already listed in `ci/defs/darwin.skip` for the same reason. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ng it on macOS `master` (b658464) replaced `hostname -i` - a Linux-only flag that fails on macOS with `hostname: illegal option -- i` - with a portable `socket.getaddrinfo` lookup in the sibling HTTP-server tests and unskipped them on the Darwin fast test. Do the same here: resolve `CLICKHOUSE_HOST` via `socket.getaddrinfo` (defaulting to `127.0.0.1`) and drop the `ci/defs/darwin.skip` entry added in the previous commit, so the redirect test keeps its macOS coverage. Fast test (arm_darwin) failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101768&sha=15dc4b5541035e75f1c56e606e99a404df23bdf8&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Addressed the AI-review / Security fix — Regression test. New integration test Fast test (arm_darwin).
|
|
Merged latest
CI is re-running on the fresh merge ( |
…ct) URI When following redirects, the final object may have a different path and extension than the dictionary source URL (e.g. `/redirect` -> `/data.csv.gz`) and the server may not send `Content-Encoding`. Detect the compression method from `ReadWriteBufferFromHTTP::getCurrentURI` (redirects are already followed, since the buffer is created with delayed initialization disabled) instead of `configuration.url`. Add a redirect-to-gzip case to the `04498` test.
…-redirects # Conflicts: # src/Dictionaries/HTTPDictionarySource.cpp
|
Addressed the remaining AI-review Major and refreshed the branch: Compression detection after redirects (commit cceaf43, includes 6407264): Merged latest The previous run's only CI failure, |
…directs Review follow-up: `createWrappedBuffer` derived the compression method only from the final (post-redirect) URI, which dropped the sole compression hint for the inverse redirect pattern - a source URL with a compression suffix (e.g. `/data.csv.gz`) redirecting to an opaque signed URL served without `Content-Encoding`. When the final URI does not imply any method and there is no `Content-Encoding`, `chooseCompressionMethod` now falls back to the path of the original `configuration.url`. Extended `04498_http_dictionary_max_redirects` with the reverse regression: a `/source.csv.gz` source that `302`s to a suffixless `/signed-token` serving the gzip object without `Content-Encoding` must still load.
|
Addressed the remaining review request (inline thread on
Both directions are now covered by the test: |
`ReadWriteBufferFromHTTP::callWithRedirects` replayed the original method and the original request body on every redirect hop. For a `303 See Other` this violates RFC 9110, 15.4.4: the follow-up request must use `GET` and must not carry the body of the original request. This is what the selective-load paths of `HTTPDictionarySource` hit: `loadIds` and `loadKeys` (used by the `cache` and `complex_key_cache` layouts) `POST` the requested keys, so a standards-compliant `303` to a signed download URL was replayed as a `POST` to that URL and typically answered with `405 Method Not Allowed`. `callWithRedirects` now rewrites the request to `GET` and suppresses the out-stream callback after a `303` (except for a `HEAD` probe, which keeps its method). The rewrite is sticky for the lifetime of the buffer, because `current_uri` keeps pointing at the redirect target across retries. `04498_http_dictionary_max_redirects` gained a selective-load regression: a `cache` dictionary whose source answers the lookup `POST` with `303` to an endpoint that serves the data on `GET` and rejects `POST` with `405`. Verified end-to-end against a fresh build; with a `302` in place of the `303` the same setup still fails with `405`, which is the expected standards-compliant behavior and confirms the test discriminates the fix.
|
Addressed the remaining AI-review Major (selective-load
Selective-load regression added to Merged latest |
…direct` `HTTPDictionarySource` now goes through `callWithRedirects`, but the loop only follows statuses recognized by `isRedirect`, which omitted `308`. A dictionary behind a standards-compliant `308` response failed in `assertResponseIsOk` instead of honoring `max_http_get_redirects`. `308` keeps the method and the body like `307`, so it needs no special handling in the redirect loop. Add a `308` case to `04498_http_dictionary_max_redirects`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Pass 2026-09-16: merged @groeneai, investigate the failures https://github.com/ClickHouse/clickhouse-private/actions/runs/34241251146/job/102120033709 ( |
|
Both failures already have a fix in progress, and neither fix is merged, so the head your sync branch built contains neither. 1. The test decides PASS/FAIL by elapsed time. A satisfied #117764 replaces the clock with the propagation itself: each exchange endpoint traces what it does when the stop reaches it, and both halves are required on every stream between the 2. Cost, not a defect: 0 timeouts on the file in 90 days of public CI, but MSan is already its worst lane ( I cannot open either private job log (the private repo is not visible to this account), so both matches rest on the public signature plus the lane, test and timing data relayed to me from the private lanes. If a log shows something else (for 05024 a stop that never propagates rather than a slow host, for 04669 an error rather than the 600 s file gate), say so and I will treat that one as new work with its own PR. |
…filter test Add a negative regression for `cache` dictionaries: `loadIds` sends the keys in a `POST` body, the allow-listed source answers with `307` to a host that is not in `remote_url_allow_hosts`, and the redirect hop must be rejected before the target is fetched. This guards against a future omission of `withHostFilter` on the selective-load builders. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| { | ||
| effective_method = Poco::Net::HTTPRequest::HTTP_GET; | ||
| with_request_body = false; | ||
| rewritten_to_get_by_redirect = true; |
There was a problem hiding this comment.
callWithRedirects now remembers a 303 See Other rewrite only here, but the same buffer can later reach code paths that bypass that state. getHeadResponse in src/IO/ReadWriteBufferFromHTTP.cpp:215 may run first on seekable formats and moves current_uri to the redirected target, while readBigAt in src/IO/ReadWriteBufferFromHTTP.cpp:778 still calls callImpl(..., method, range, false) with the original POST. So a POST -> 303 -> GET source still breaks as soon as the reader does metadata or range reads (for example Parquet via src/Processors/Formats/Impl/Parquet/Prefetcher.cpp:65 and src/Processors/Formats/Impl/Parquet/Prefetcher.cpp:109): after the HEAD probe or first random read we hit the signed object with POST instead of GET.
Please carry the effective method / body suppression through those direct callImpl paths (or avoid persisting a HEAD-discovered target without the matching rewrite) and add a focused seekable-format regression.
There was a problem hiding this comment.
🕵 This PR is already merged (2026-10-04), so no more commits can go into it. My assessment of this comment:
- The path is not a regression from this PR. Before the change, every redirect,
303included, replayed the original method and body. AHEADprobe fromgetHeadResponsealready movedcurrent_uri, andreadBigAtalready usedmethod. The PR only adds303 -> GEThandling tocallWithRedirects. - On master the only readers that use
POSTareXDBC(bridge, non-seekable streaming format) andHTTPDictionarySource::loadIds/loadKeys.loadAll/loadUpdatedAlluseGET. To hitPOST -> 303 -> GETwith aHEADprobe orreadBigAt, an HTTP dictionary would need a seekable format such asParquet, a key-based load, and a server that answers thePOSTwith303to a range-capable object. That is a narrow combination.
If it needs fixing, the fix is small: set rewritten_to_get_by_redirect on a 303 seen during the HEAD probe too (the HEAD still keeps its own method), and have readBigAt use GET without the request body when the flag is set. It should go in a separate follow-up PR with a focused test, not here.
Carry the port of the cherry-pick as a tree onto the rebuilt `backport/26.3/129850` branch: the release branch was rewritten, so the earlier port cannot be pushed as is without bringing the old history back. This branch has no `web` disk, no index pages listing and no `Elasticsearch`, so the change is ported instead of cherry-picked. Deviations from the original change, all approved: - `StorageURLSource::setCredentials` is rewritten to call `checkBasicCredentials`; the check runs before the `try` in `getFirstAvailableURIAndReadBuffer`, and the initiator of `urlCluster` checks all failover options. - The schema registry check is in `SchemaRegistry::fetchSchema` in `AvroRowInputFormat.cpp`. - `checkAndNormalizeHeaders` is called instead of `checkHeaders`. - `HTTPDictionarySource` keeps the `created_from_ddl` field of `Configuration` from #101768, which the original change relies on. - The changes of the `web` disk, `test_disk_over_web_server`, `Elasticsearch` and `web_index` are dropped, they do not exist on this branch. - `test_storage_url` gets 11 ported test cases, and `configs/conf.xml` a placeholder `http_forbid_headers`.
Carry the conflict resolution of the cherry-pick as a tree onto the rebuilt `backport/26.9/129850` branch: the release branch was rewritten, so the earlier resolution cannot be pushed as is without bringing the old history back. Deviations from the original change, all approved: - `HTTPDictionarySource` keeps the `created_from_ddl` field of `Configuration` from #101768, which the original change relies on. - The `Elasticsearch` hunk and the `test_storage_elasticsearch` changes are dropped, the engine does not exist on this branch. - `checkAndNormalizeHeaders` is called instead of `checkHeaders`. - `test_storage_url` gets the helper `server_part_of_error` for the error assertions. - The redirect fixture of `index_pages_server.py` puts userinfo into `Location` as on master (from #126184), so that `test_url_redirect_userinfo_is_not_sent_with_forbidden_authorization` exercises the redirect with credentials. The masking of the URL in the error of `rejectOriginChangingRedirect` from #126184 is not ported: it is not part of this change, and the branch keeps its existing behavior.
Carry the conflict resolution of the cherry-pick as a tree onto the rebuilt `backport/26.8/129850` branch: the release branch was rewritten, so the earlier resolution cannot be pushed as is without bringing the old history back. Deviations from the original change, all approved: - `HTTPDictionarySource` keeps the `created_from_ddl` field of `Configuration` from #101768, which the original change relies on. - The `Elasticsearch` hunk and the `test_storage_elasticsearch` changes are dropped, the engine does not exist on this branch. - `checkAndNormalizeHeaders` is called instead of `checkHeaders`. - `test_storage_url` gets the helper `server_part_of_error` for the error assertions. - The tests use the setting name `allow_experimental_url_wildcard_from_index_pages`, as it is named on this branch. - The redirect fixture of `index_pages_server.py` puts userinfo into `Location` as on master (from #126184), so that `test_url_redirect_userinfo_is_not_sent_with_forbidden_authorization` exercises the redirect with credentials. The masking of the URL in the error of `rejectOriginChangingRedirect` from #126184 is not ported: it is not part of this change, and the branch keeps its existing behavior.
What this PR does
HTTPDictionarySourcedid not callwithRedirectson its HTTP request builder, so HTTP dictionary sources rejected every redirect withTOO_MANY_REDIRECTSeven whenmax_http_get_redirectswas set to a non-zero value. This made it impossible to create dictionaries from HTTP(S) URLs that redirect (e.g. pre-signed object-storage URLs), while theurltable function and other HTTP sources already follow redirects.This adds
.withRedirects(context->getSettingsRef()[Setting::max_http_get_redirects])to all four request paths (loadAll,loadUpdatedAll,loadIds,loadKeys), matching the pattern already used inStorageURL. Themax_http_get_redirectsvalue is taken from the dictionary'sSETTINGSclause; the default of0keeps the previous (redirect-rejecting) behavior, so this is not backward incompatible.A new stateless test
04498_http_dictionary_max_redirectsstarts a local HTTP server that issues a302redirect and verifies that the dictionary refuses to follow it whenmax_http_get_redirects = 0(TOO_MANY_REDIRECTS) and loads successfully when redirects are allowed.Closes: #90521
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes):
HTTP dictionary sources (
SOURCE(HTTP(...))) now respect themax_http_get_redirectssetting, so dictionaries can be created from URLs that redirect. Previously such dictionaries always failed withTOO_MANY_REDIRECTS.Workflow [PR]
Sync PR [sync-upstream/pr/101768]
Version info
26.10.1.1490-master(included in26.10and later)