Skip to content

Fix readability-container-contains in gtest_aggregating_step_settings_roundtrip - #114872

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
valerypetrov:fix-contains-aggregating-gtest
Aug 14, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
valerypetrov:fix-contains-aggregating-gtest

Conversation

@valerypetrov

@valerypetrov valerypetrov commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes: (none — master tidy breakage)

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

3c9cdbb1831 left a find(...) != std::string::npos membership check in gtest_aggregating_step_settings_roundtrip.cpp:54; clang-tidy's readability-container-contains (warnings-as-errors) fails the arm_tidy build of any PR that CI merges with current master (observed on #114665). One-line contains() fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr

Version info

  • Merged into: 26.8.1.1447 (included in 26.8 and later)

…_roundtrip

clang-tidy (-warnings-as-errors) rejects the `find(...) != npos` membership
check introduced by 3c9cdbb, which currently fails the arm_tidy build of
every PR merged with master. Use contains().

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XvXEBdaJTCCnUdunCf8icr
@valerypetrov

Copy link
Copy Markdown
Contributor Author

@groeneai , please verify this one.

@clickhouse-gh

clickhouse-gh Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f707f2c]

Summary: ⏳

job_name test_name status info comment
Stateless tests (amd_tsan, parallel) FAIL
00938_fix_rwlock_segfault_long FAIL cidb

AI Review

Summary

This PR replaces a find(...) != std::string::npos membership check in gtest_aggregating_step_settings_roundtrip.cpp with contains(...) so the test TU passes clang-tidy's readability-container-contains check under the current toolchain. The change is mechanically equivalent, matches existing precedent in the same area, and I found no correctness, coverage, or PR-metadata issues.

Final Verdict

✅ No findings. The change looks correct as-is.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 14, 2026
@vitlibar vitlibar self-assigned this Aug 14, 2026
@vitlibar vitlibar added the can be tested Allows running workflows for external contributors label Aug 14, 2026
@vitlibar

Copy link
Copy Markdown
Member

Broken in #112131

@groeneai

Copy link
Copy Markdown
Collaborator

Verified.

The breakage is mine: #112131 added that find(...) != npos line and merged as 9fdec342, the exact master sha whose Build (arm_tidy) went red 37 minutes later. The preceding sha 34774aec was green. Build (arm_tidy) passed on every run of my PR because its last tidy run was on 2026-08-08, before #108400 bumped ToolSet.COMPILER_C to clang-22, so the PR run and the post-merge master run used different analyzers.

Your change is correct and complete for this file:

  • I ran clang-tidy-22 against this TU's real compile flags from compile_commands.json. Before: exit 1 with the same finding at the same position CI reports, 54:22 readability-container-contains. After: exit 0, zero findings, and no unresolved-member diagnostic, so contains resolves under the C++23 pin (CMAKE_CXX_STANDARD 23, libc++ __cpp_lib_string_contains).
  • std::string::contains(const char *) is specified as find(x) != npos, so the membership assertion the gtest makes is unchanged.
  • No find(...) != npos occurrence is left in the file at f707f2c3.
  • The failing master job ran ninja -k0 and reached 17528/17530 with exactly one failed object, so line 54 was the only tidy error on that sha. This one-liner should be all it takes.

It also matches existing precedent: gtest_packed_string_keys_plan_setting.cpp got the identical treatment in #113898.

To be clear on scope, this fixes the gtest_aggregating_step_settings_roundtrip.cpp carrier only. Other branches that were tidy-green before the clang-22 bump are a separate tail.

No findings from me. Tagging @thevar1able for review, since he made both the clang-22 bump and that sibling fix.

Thanks for turning this around 12 minutes after it broke.

@vitlibar
vitlibar enabled auto-merge August 14, 2026 19:28
@alexey-milovidov

Copy link
Copy Markdown
Member

Confirming this from the MasterCI side, with the root cause, since the "why did CI let it through" part is not obvious.

Failing report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=b03544a19bc3e7046b8ac5eb6467bf444f295038&name_0=MasterCI&name_1=Build%20%28arm_tidy%29

The line came in with #112131 (commit 424f52b4df5, merged as 9fdec34202f on 2026-08-14 17:48). That pull request's Build (arm_tidy) was green — and not because the check was skipped or served from cache. It really ran clang-tidy on this exact file and found nothing:

[17449/17451] Building CXX object src/CMakeFiles/unit_tests_dbms.dir/Processors/QueryPlan/tests/gtest_aggregating_step_settings_roundtrip.cpp.o
DEBUG:clang-tidy-cache.py:Digest 52c15b11fc72f4c302f510b57840052768ff04e1 does not exist in cache.
DEBUG:clang-tidy-cache.py:Calling real clang-tidy.
164785 warnings generated.

That run was on 2026-08-08 13:33, under clang-tidy-21. In between, #108400 (Use clang-22, merged 2026-08-10 17:33) switched CI to clang-tidy-22, whose readability-container-contains also matches std::string::find compared against std::string::npos and suggests std::string::contains; clang-tidy-21 does not flag that shape. #112131 then merged six days after its last tidy run, so nothing re-checked it against the new toolchain, and the failure surfaced on the very next master commit. In short: a stale-green tidy result that predates the compiler bump, not a gap in the check itself.

Two follow-on points, both of which argue that this one-line change is the whole fix:

  • The file bytes are identical at Serialize serialize_string_in_memory_with_zero_byte in the query plan #112131's head 3c9cdbb1831 and at master b03544a19bc, yet the ctcache digest differs (52c15b11… on the pull request versus 59178868… on master). clang_tidy_cache.py folds the preprocessed compiler output into the digest, so clang-21 → clang-22 invalidated the entire clang-tidy cache. Every other translation unit was therefore re-checked under clang-tidy-22 during the green 2026-08-10 → 2026-08-14 master window. This file is the only latent instance, not the first of a batch — consistent with the master build reporting exactly one FAILED target under ninja -k0.
  • The other find(...) != std::string::npos sites under src are all either multi-argument find calls or use the returned position, so contains does not apply to them. The one exception, src/Processors/tests/gtest_exception_on_incorrect_pipeline.cpp:64, is not reported by clang-tidy-22 — it is spelled as an ASSERT_TRUE macro argument, and in the failing master build it came back as a cache hit on a clean clang-tidy-22 verdict.

I reproduced the same change independently and built the translation unit locally before finding this pull request; Build (arm_tidy) is already SUCCESS here, so this only needs the rest of CI. Not opening a duplicate.

@clickhouse-gh

clickhouse-gh Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing f707f2c3e with master 9fdec3420 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of b03544a19; 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 693.42 MiB 690.40 MiB -3.01 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

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

Median compile-time ratio to the baselines is ×0.95 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost -12.4 s (-6%) in total before that adjustment.

Job report

@alexey-milovidov
alexey-milovidov merged commit c8dacba into ClickHouse:master Aug 14, 2026
248 of 355 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-ci 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.

5 participants