Skip to content

refactor(coderd): share the deployment chat setting PUT handler - #31018

Open
ibetitsmike wants to merge 1 commit into
mainfrom
mike/chat-settings-shared-handlers-put
Open

ibetitsmike wants to merge 1 commit into
mainfrom
mike/chat-settings-shared-handlers-put

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Seven deployment chat setting PUT handlers repeated the same steps: start the audit entry, check the deployment config update permission, decode the body, run the audited write, and write the 500 or 204. This PR moves those steps into one generic putChatOperationalSetting, so each handler keeps only its validation and upsert. The three day settings share validateChatSettingDays, and initChatOperationalSettingsAudit is inlined into the helper because only these handlers used it. The PR adds 105 lines and removes 239.

The seven handlers set personal model overrides, the computer use provider, debug logging, the workspace TTL, chat retention days, debug retention days, and auto-archive days.

What changes: the workspace TTL handler loses a branch that turned a not-found or not-authorized write error into a 404. The branch cannot run: GetChatSiteConfigValue is an aggregate that always returns a row, and it and UpsertChatWorkspaceTTL check the same deployment config update permission that the handler checks first. The other six handlers never had the branch.

Why it is safe: each handler has its own coderd test, and TestChatOperationalSettingsAudit writes all seven settings and checks their audit entries. I also ran a throwaway test, not part of this PR, that sends 98 requests to the seven endpoints as an admin and as a member, with valid, unchanged, out-of-range, wrongly typed, and malformed bodies, and reads each setting back after every write. The status codes, response bodies, and audit entries are identical on main and on this branch.

Review focus: the prepare callback, which returns the audited value and the write, or a 400 response.

#31036 fixes an overflow in the workspace TTL handler on main by checking the 30-day maximum before the duration conversion. It conflicts with this PR in that handler, so whichever merges second will merge main and keep that check.

Validation: on main and on this branch, go test ./coderd -run '^(TestChatPersonalModelOverridesAdminSettings|TestChatComputerUseProvider|TestChatDebugLoggingSettings|TestChatWorkspaceTTL|TestChatRetentionDays.*|TestChatDebugRetentionDays|TestChatAutoArchiveDays|TestAuditedChatOperationalSettingWrite.*)$' -count=1 passes (11 tests, 27 with subtests) and go test ./enterprise/coderd -run '^TestChatOperationalSettingsAudit$' -count=1 passes (17 with subtests). The pre-commit hook passed (make gen, formatting, golangci-lint, slim build).

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

Seven deployment chat setting PUT handlers repeated the same audit,
authorization, decode, audited write, and response code. Move that into
putChatOperationalSetting so each handler keeps only its validation and
upsert, and share the 0 to maximum day check of the three day settings.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T22:49:55.398849Z 86c19bd Draft marked ready
ℹ️ 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. Keep them coming!

Reviewed commit: 86c19bd6cd

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