fix(coderd): reject API operations on archived chats (#24633)

Archived chats accept mutations (messages, edits, queued-message
promotions, tool-result submissions) via the API, causing them to
re-enter the processing pipeline. This violates the hard-stop
design intent from PR #23758.

Add archived checks at three layers:

- HTTP handlers (postChatMessages, patchChatMessage,
  promoteChatQueuedMessage, postChatToolResults): return 400
  after auth so callers get a clear error.
- Daemon functions (SendMessage, EditMessage, PromoteQueued,
  SubmitToolResults): return ErrChatArchived after row lock,
  guarding against future callers that bypass the handler.
- AcquireChats SQL: filter out archived chats so they are never
  acquired for processing.

Fixes CODAGT-245
This commit is contained in:
Mathias Fredriksson
2026-04-23 19:03:33 +03:00
committed by GitHub
parent a13f7f18e5
commit f8fe5d680b
6 changed files with 437 additions and 0 deletions
+1
View File
@@ -5077,6 +5077,7 @@ WHERE
chats
WHERE
status = 'pending'::chat_status
AND archived = false
ORDER BY
updated_at ASC
FOR UPDATE
+1
View File
@@ -695,6 +695,7 @@ WHERE
chats
WHERE
status = 'pending'::chat_status
AND archived = false
ORDER BY
updated_at ASC
FOR UPDATE