Skip to content

AI func named collection allow missing api key - #105701

Merged
george-larionov merged 4 commits into
masterfrom
ai-func-named-collection-allow-missing-api-key
May 29, 2026
Merged

george-larionov merged 4 commits into
masterfrom
ai-func-named-collection-allow-missing-api-key

Conversation

@george-larionov

@george-larionov george-larionov commented May 23, 2026 •

Copy link
Copy Markdown
Member

Will be merged only after #102922.

Changelog category (leave one):

  • Experimental Feature

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

Removing requirement for api key in AI credential named collections.


Note

Medium Risk
Changes validation and request construction so AI providers may be called without an API key, which can alter authentication behavior and lead to unexpected unauthenticated requests if misconfigured.

Overview
AI named collections no longer require api_key; FunctionBaseAI::resolveAINamedCollection stops throwing when it’s missing.

Both OpenAIProvider (chat + embeddings) and AnthropicProvider now only send auth headers (Authorization / x-api-key) when api_key is non-empty.

Tests are updated to expect successful resolution/execution with a named collection that omits api_key, instead of a BAD_ARGUMENTS failure.

Reviewed by Cursor Bugbot for commit f256771. Bugbot is set up for automated code reviews on this repo. Configure here.

Version info

  • Merged into: 26.6.1.246 (included in 26.6 and later)
  • Backported to: 26.5.6.88

@george-larionov
george-larionov changed the base branch from master to feature/ai-embeddings May 23, 2026 13:57
@clickhouse-gh

clickhouse-gh Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [feba343]

Summary: ❌

job_name test_name status info comment
BuzzHouse (amd_msan) FAIL
MemorySanitizer: use-of-uninitialized-value (STID: None) FAIL cidb, issue ISSUE CREATED

AI Review

Summary

This PR makes api_key optional for AI named collections, skips provider auth headers when the key is absent, and updates the AI function docs plus stateless coverage for a no-key request path. The follow-up commits address the previous review points around stale documentation and zero-row-only coverage, and I did not find remaining correctness, safety, or documentation issues that need inline comments.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-experimental Experimental Feature submodule changed At least one submodule changed in this PR. labels May 23, 2026
@george-larionov
george-larionov marked this pull request as ready for review May 23, 2026 13:58
@george-larionov
george-larionov requested a review from pjhampton May 23, 2026 13:58
Comment thread src/Functions/FunctionBaseAI.cpp Resolved
@rschu1ze rschu1ze self-assigned this May 26, 2026
Comment thread contrib/azure Resolved
Comment thread src/Functions/AI/OpenAIProvider.cpp Resolved
Base automatically changed from feature/ai-embeddings to master May 27, 2026 20:29
george-larionov and others added 2 commits May 27, 2026 21:53
Update the FunctionBaseAI contract comment, all per-function docs
(`aiGenerate`, `aiClassify`, `aiExtract`, `aiTranslate`, `aiEmbed`), and
the AI named-collection reference docs to state that `api_key` is
optional. Add a non-empty-row test case that drives the no-`api_key`
path through provider construction and an actual HTTP request
(swallowed via `ai_function_throw_on_error = 0`), so the runtime
behavior is exercised — the previous assertion ran over a zero-row
table and returned before `createAIProvider` was reached.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@george-larionov
george-larionov force-pushed the ai-func-named-collection-allow-missing-api-key branch 2 times, most recently from 71ceb8e to e11323a Compare May 27, 2026 21:57
…_key

Mirror the existing `not all providers need API key` comment on the
`OpenAIProvider::call` path to the `OpenAIProvider::embed` path and to
`AnthropicProvider::call`, so all three auth-header guards explain
the same rationale.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@george-larionov george-larionov removed the submodule changed At least one submodule changed in this PR. label May 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.40% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 77.00% 77.00% +0.00%

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

Full report · Diff report

@george-larionov

Copy link
Copy Markdown
Member Author

One test failure, memory sanitizer issue, will investigate separately.

@george-larionov george-larionov changed the title Ai func named collection allow missing api key AI func named collection allow missing api key May 29, 2026
@george-larionov
george-larionov added this pull request to the merge queue May 29, 2026
Merged via the queue into master with commit 9afcd1b May 29, 2026
164 of 167 checks passed
@george-larionov
george-larionov deleted the ai-func-named-collection-allow-missing-api-key branch May 29, 2026 22:34
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label May 29, 2026
pull Bot pushed a commit to muzammilar/ClickHouse that referenced this pull request May 31, 2026
BuzzHouse/AST-fuzzer jobs run `clickhouse-server` with its stderr piped
through `tee` into `stderr.log` and `server.log`. Sanitizer reports
(MSan/ASan/TSan/UBSan) and the in-process LLVM symbolizer write to that
stderr. When the server aborts, the pipe's reader can go away, so the
report write fails with `IO failure on output stream: Broken pipe` and is
truncated before any stack frame is printed.

When the report has no parseable frames, `log_parser.py` cannot compute a
stack-trace id and names the failure `... (STID: None)`. The CI
failure-matcher then groups every stack-less sanitizer failure under a
single auto-generated issue, regardless of the real root cause, so
unrelated bugs across different PRs all look like one recurring failure.

Set `*_OPTIONS=log_path=/workspace/sanitizer.log` for the fuzzer server so
the runtime writes the report to a regular file, which is robust to the
stderr pipe breaking. After the server stops, the captured files are
merged back into `stderr.log` (for the failure parser) and `server.log`
(for chronological context and the OOM detection that greps it), and the
raw files are uploaded as artifacts. With the report preserved, the parser
can compute a real stack-trace id and distinct failures stop collapsing
into one issue.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/105701/feba3438e46f861025a0cb811816a3138cdb67d9/buzzhouse_amd_msan/
PR: ClickHouse#105701
Issue: ClickHouse#106138

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 30, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 30, 2026
george-larionov added a commit that referenced this pull request Jul 30, 2026
Backport #105701 to 26.5: AI func named collection allow missing api key
george-larionov added a commit that referenced this pull request Jul 31, 2026
26.5 gained #105701 (`api_key` optional) and #107927 (retry transient network
errors) after this backport branch was cut, so the conflict resolution keeps both
and drops the earlier `api_key`-required adaptation. `aiEmbed` stays at the master
signature `aiEmbed(text, model[, params])`; `introduced_in` stays 26.5.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-experimental Experimental Feature pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.4-must-backport v26.6-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants