Skip to content

refactor: delete the ChatProviderAPIKeys test seam - #30927

Draft
ibetitsmike wants to merge 3 commits into
mainfrom
mike/coderdtest-drop-provider-keys
Draft

ibetitsmike wants to merge 3 commits into
mainfrom
mike/coderdtest-drop-provider-keys

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

This PR deletes coderd.Options.ChatProviderAPIKeys, its coderdtest.Options copy, and the coderdtest.OpenAICompatProviderAPIKeys and coderdtest.FakeOpenAICompatProviderAPIKeys helpers. Only tests set the option. newChatTestOptions and 27 other chat, MCP, and toolsdk fixtures used it to start a fake OpenAI-compatible server whose fallback keys no model call reads.

Why it is safe

  • Model calls never read the fallback keys. newModel builds the client from fantasyConfigForAIBridge, which returns AI Gateway placeholder keys (coderd/x/chatd/model_routing_aibridge.go).
  • Key resolution for a selected provider passes empty fallback keys (resolveUserProviderAPIKeysForProvider in chatd.go), and so does the HTTP availability check in coderd/exp_chats.go. Active model configs always have an ai_provider_id (the chat_model_configs_ai_provider_required_when_active check constraint).
  • The only path that merges chatd.Config.ProviderAPIKeys is the provider-type lookup for the computer-use subagent. It asks only for anthropic or openai, and the test keys were stored only under openai-compat.
  • Model-backed tests get their key and base URL from the DB provider that CreateOpenAICompatChatModel creates.
  • git grep -n 'ChatProviderAPIKeys\|OpenAICompatProviderAPIKeys' matches nothing after the change.

Review focus

coderd.go no longer passes ProviderAPIKeys to chatd.Config. Production never set ChatProviderAPIKeys, so chatd gets the zero value it always got in production. chatd.Config.ProviderAPIKeys stays for now, because chatd internal tests still set it directly.

Validation

Each suite ran before the change (on e289c6fe011) and after it, with the same results:

  • go test ./coderd/ -run '(?i)chat|mcp' -count=1 -p 4 -parallel 4 -v: pass, 163 top-level tests, 899 PASS lines, 0 failures, same test set both times.
  • go test ./codersdk/toolsdk/ -count=1 -parallel 4 -v: pass, 234 PASS lines, 0 failures.
  • go test ./coderd/coderdtest/... -count=1 -v: pass, 350 PASS lines, 0 failures.
  • go build ./..., go vet on the touched packages and ./enterprise/coderd/..., and golangci-lint run --fix=false ./coderd/ ./coderd/coderdtest/... ./codersdk/toolsdk/...: clean.
  • make pre-commit: passed.

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

coderd.Options.ChatProviderAPIKeys and its coderdtest copy were set only
by tests. newChatTestOptions and the MCP and toolsdk fixtures used them
to start a fake OpenAI-compatible server whose fallback keys no model
call read: chat model configs always carry an AI provider ID, and
model calls route through AI Gateway with placeholder keys.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T17:30:11.459371Z 37532af Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 9b0c1dd9c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for Mike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 37532afc22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant