Skip to content

test(coderd/x/chatd): cover BYOK header choice for Bedrock and OpenAI-compatible routes - #30978

Draft
ibetitsmike wants to merge 3 commits into
mike/chatd-gateway-only-transport-branchesfrom
mike/chatd-gateway-byok-header-test
Draft

ibetitsmike wants to merge 3 commits into
mike/chatd-gateway-only-transport-branchesfrom
mike/chatd-gateway-byok-header-test

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

TestResolveModelRouteForConfigAIGatewayProviderAuth gains one subtest that pins which header carries a user's own provider key on two more routes: X-Api-Key for an Anthropic model on a Bedrock provider, and Authorization: Bearer for an OpenAI-compatible provider. The next layer rewrites how chatd picks that header, and until now no test failed when the call site dropped the model ID. This test-only layer is the characterization test for that rewrite, so it adds lines instead of removing them.

Why it is needed

  • resolveAIGatewayRoute passes the model ID to aiGatewayRequestFormatForProviderType, and only the Bedrock arm reads it. A mutant that passes "" instead passed all of go test ./coderd/x/chatd/: no chatd test resolved a BYOK route for a Bedrock provider, and TestAIGatewayRequestFormatForProviderType calls the classifier directly.
  • With this subtest, that mutant fails on the Bedrock row (X-Api-Key expected, Authorization sent). A mutant that maps the classifier's default arm to the Anthropic format fails on the OpenAI-compatible row. A garbage copy of model_routing_aibridge.go fails to build, so the -overlay applies.

Review focus

Today the OpenAI-compatible row takes the same default arm as the OpenAI UserKey subtest. The next layer keys the header on the client family (anthropic, openai, openai-compat), and this row fails if that switch matches only openai.

Validation

  • go test ./coderd/x/chatd/ -run '^TestResolveModelRouteForConfigAIGatewayProviderAuth$' -count=1: pass.
  • Both mutants above, through go test -overlay: fail the new subtest.
  • go test ./coderd/x/chatd/ -count=1 -p 4 -parallel 4: pass.
  • make pre-commit: pass.

Stack

This stack removes provider code that only direct, non-gateway clients used, so chatprovider builds just the three clients the AI Gateway path needs; #30979 then derives the BYOK auth header from that same client choice.

  1. refactor(coderd/x/chatd/chatprovider): drop the direct Bedrock client #30928 Drop the direct Bedrock client
  2. refactor(coderd/x/chatd): drop the remaining direct provider clients #30929 Drop the remaining direct provider clients
  3. refactor(coderd/x/chatd/chatprovider): drop provider options only direct clients read #30958 Drop provider options only direct clients read
  4. refactor(coderd/x/chatd): drop transport branches only direct clients used #30966 Drop transport branches only direct clients used
  5. test(coderd/x/chatd): cover BYOK header choice for Bedrock and OpenAI-compatible routes #30978 Cover the BYOK header choice for Bedrock and OpenAI-compatible routes
  6. refactor(coderd/x/chatd): derive the BYOK auth header from the AI Gateway client choice #30979 Derive the BYOK auth header from the client choice

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

@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:35:35.999791Z c8b17f6 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. Breezy!

Reviewed commit: cd4c95f171

ℹ️ 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. You're on a roll.

Reviewed commit: c8b17f6f74

ℹ️ 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