Repository navigation
refactor(coderd): share the chat model config write error mapping - #31019
Open
ibetitsmike wants to merge 1 commit into
Open
ibetitsmike wants to merge 1 commit into
ibetitsmike wants to merge 1 commit into
Conversation
Create, update, and delete of chat model configs each mapped transaction errors to responses with their own switch. Share update's mapping in writeChatModelConfigWriteError.
Collaborator
Author
|
@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. What shall we delve into next? 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". |
ibetitsmike
marked this pull request as ready for review
October 19, 2026 22:48
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create, update, and delete of chat model configs each mapped their transaction errors to responses with their own
switch. This PR moves update's mapping intowriteChatModelConfigWriteErrorand calls it from all three handlers, with each handler's500message as an argument. It adds 33 lines and removes 69.What changes: every handler now has every case of update's mapping. Create gains the
404case, and delete gains the412,400, and409cases. The delete transaction returns none of those errors. Create returns a not-found error only if a row it reads disappears inside its transaction, which holds the organization's model config write lock; before, that was a500.Why it is safe: I ran 7 mutants of
writeChatModelConfigWriteErrorand its callers withgo test -overlay. The tests below fail on 5: skip the precondition check, return500for a provider model error, return404instead of403for an authorization error, return500for a not-found error, and change the500message. Two survive onmainas well:409case: the only unique index besides the primary key allows one default config per organization, and every writer changes the default under the write lock, so no test can reach it.500message: no test makes delete fail with a500. The message is the same literal as onmain.Review focus: the order of the
403and404cases.httpapi.Is404Erroralso matches authorization errors, so the403case stays first, as in update's mapping.Validation: on
mainand on this branch,go test ./coderd -run '^(TestCreateChatModelConfig|TestUpdateChatModel|TestDeleteChatModelConfig|TestChatModelConfigAudit|TestChatModelActionScopesWithOrgRead|TestCreateChatModelRejectsACLKeys|TestChatModelReasoningMode.*|TestChatModelACLShareDenied)$' -count=1passes (10 tests, 103 with subtests). The pre-commit hook passed (make gen, formatting, golangci-lint, slim build).