Repository navigation
refactor(coderd/x/chatd/chattest): drop write-only fake state and share the shape check - #30950
ibetitsmike wants to merge 3 commits into
Conversation
…re the shape check
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review
|
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
The OpenAI and Anthropic fakes stored each request in a
requestfield under a mutex that nothing read, and kept thehttptest.Serverin a field that only their constructors used. This PR deletes both fields, the mutex and its lock blocks. It also merges the three copies of the response-shape switch into oneresponseShapeErrorhelper, and the two copies of the OpenAI request decode intodecodeOpenAIRequest.Why it is safe
request, so dropping it and its mutex changes no behavior.responseShapeErrorreturns the same four strings, byte for byte, in the same order. Each writer still checksresp.Errorfirst, writes the same plain-text 500 withhttp.Error, and keeps its own serializers. The layer below pins the "both" and "empty" errors, and the existing mismatch tests pin the other two: removing any case from the helper fails one of them.decodeOpenAIRequestreturns the read or decode error unwrapped, so the 400 body is unchanged, andhandleResponsesstill runsValidateResponsesAPIInputbefore the handler. It setsRawBodyafter decoding, as both copies did, so the field comment no longer claims it is set before.Review focus
The writers now use
switch msg := responseShapeError(...); { case msg != "": ... }, which leaves the streaming and non-streaming cases as they were.Validation
go test ./coderd/x/chatd/chattest/ -count=1: ok before and aftergo test -race ./coderd/x/chatd/chattest/ -count=1: okgo test ./coderd/x/chatd/ -count=1 -p 4 -parallel 4: ok before and aftergo vet ./coderd/x/chatd/chattest/: okgolangci-lint run --fix=false ./coderd/x/chatd/chattest/: 0 issuesStack
The stack makes the chattest fake tests fail on wrong output, then drops the fakes' write-only state and shares their response-shape check.