Skip to content

Add test: Duplicate TLS argument rejection and positional-arity stripping untested - #114580

Merged
PedroTadim merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr110615
Aug 14, 2026
Merged

PedroTadim merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr110615

Conversation

@clickgapai

Copy link
Copy Markdown
Contributor

Test-only PR. Review: are the gaps real, is the test right.

Adds test coverage for 1 untested code path, found during automated review of PR #110615.
That PR: (1) Adds TLS/SSL to every PostgreSQL integration: sslmode plus certificate/key either as server-local paths (sslrootcert/sslcert/sslkey, config-only) or as literal contents (*_pem, accepted from SQL, materialized into TemporarySecretFile and masked as secrets). New code: …

1. Duplicate TLS argument rejection and positional-arity stripping untested
src/Storages/StoragePostgreSQL.cpp:726, src/Databases/PostgreSQL/DatabasePostgreSQL.cpp:573
Risk: StoragePostgreSQL::extractSSLParamsFromArguments strips trailing TLS key = value pairs and rejects repeats at StoragePostgreSQL.cpp:726-727; the stripped list then feeds the arity check at DatabasePostgreSQL.cpp:573. Risk if broken: a repeated sslmode = 'require', sslmode = 'disable' …
Unique vs PR tests: 04820 formats queries with distinct TLS keys and checks masking plus path rejection; 04846 checks query-tree masking; test_postgresql_ssl exercises real handshakes through named collections. None repeats a TLS key (the specified more than once branch) and none combines the maximum positional …
Tags: -- Tags: no-fasttest — no-fasttest: the PostgreSQL integration is not built in the fast test build; the PR's own 04820 uses the same tag

cc @alexey-milovidov (author of #110615) — could you take a look, and add the can be tested label if this looks good?

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickgapai

Copy link
Copy Markdown
Contributor Author
Pre-PR validation: 6/6 ✅

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/StoragePostgreSQL.cpp:726 if (!values.emplace(key, ...).second) throw ... 'specified more than once' and the --num_positional_arguments / arguments.resize stripping that the arity check at src/Databases/PostgreSQL/DatabasePostgreSQL.cpp:573 depends on — both untested.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04869_postgresql_tls_trailing_arguments.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@PedroTadim PedroTadim self-assigned this Aug 13, 2026
@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3888bf7]

Summary: ✅


AI Review

Summary

This PR adds a stateless PostgreSQL regression test for duplicate trailing TLS arguments and the positional-argument stripping that follows them. The duplicate-argument checks are useful, but the positive PostgreSQL table-engine case still does not make a table-engine stripping regression observable, so the stated coverage gap is not fully closed yet.

Findings

⚠️ Majors

  • [tests/queries/0_stateless/04869_postgresql_tls_trailing_arguments.sql:19] StoragePostgreSQL::getConfiguration accepts 5 to 7 positional arguments. This case uses six positional arguments plus one trailing sslmode, so if extractSSLParamsFromArguments stops stripping the TLS argument, the statement still arrives with seven arguments and continues to pass. That means the test does not fail when the table-engine stripping regresses, even though the file comment says the trailing arguments must not count toward positional arity.
    Suggested fix: use all seven positional slots before sslmode (for example, add an on_conflict argument) so an unstripped TLS argument becomes an eighth argument and reliably raises NUMBER_OF_ARGUMENTS_DOESNT_MATCH.
Final Verdict
  • Status: ⚠️ Request changes
  • Make the positive PostgreSQL table-engine case fail when trailing TLS arguments are not stripped.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3888bf7d5 with master 65d9cadd3 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 5def5b67e; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 691.74 MiB 688.75 MiB -2.98 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline.

Job report

@PedroTadim

Copy link
Copy Markdown
Member

@clickgapai check the CI failures

@clickgapai

Copy link
Copy Markdown
Contributor Author

@PedroTadim the flaky-check failures were this PR's own test: it created a fixed-name database (db_04869) and the flaky check runs the test many times in parallel, so the runs collided on Database db_04869 already exists. Switched to the per-run {CLICKHOUSE_DATABASE_1} macro and re-running CI.

CREATE DATABASE {CLICKHOUSE_DATABASE_1:Identifier} ENGINE = PostgreSQL('127.0.0.1:1', 'd', 'u', 'p', 'sch', 1, sslmode = 'require');
SELECT engine FROM system.databases WHERE name = {CLICKHOUSE_DATABASE_1:String} ORDER BY 1;

CREATE TABLE t_04869 (x Int32) ENGINE = PostgreSQL('127.0.0.1:1', 'd', 't', 'u', 'p', 'sch', sslmode = 'require');

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.

StoragePostgreSQL::getConfiguration accepts 5 to 7 positional arguments, so this case is still valid even if extractSSLParamsFromArguments stops stripping the trailing sslmode: it would arrive as seven arguments (host, db, table, user, password, schema, sslmode = ...) and keep passing. That means the table-engine half of "trailing arguments must not count towards the positional ones" is not actually observable here. Could we spend the last positional slot too, for example by adding an on_conflict argument before sslmode, so a regression turns into NUMBER_OF_ARGUMENTS_DOESNT_MATCH?

@PedroTadim
PedroTadim added this pull request to the merge queue Aug 14, 2026
Merged via the queue into ClickHouse:master with commit 5bf7348 Aug 14, 2026
182 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants