fix(coderd): reject pinning child chats in patchChat handler (#24669)

The UI already prevents child (delegated/subagent) chats from being
pinned, but the `PATCH /api/experimental/chats/{chat}` endpoint did not
enforce this. A direct API call could pin a child chat.

- Add a `400 Bad Request` guard in `patchChat` when `pinOrder > 0` and
the chat has a `ParentChatID`
- Add `TestChatPinOrder/RejectsChildChat` test

> 🤖
This commit is contained in:
Cian Johnston
2026-04-23 18:36:20 +01:00
committed by GitHub
parent dbcc654d28
commit c602a31856
7 changed files with 162 additions and 5 deletions
+3 -1
View File
@@ -1483,7 +1483,9 @@ CREATE TABLE chats (
dynamic_tools jsonb,
organization_id uuid NOT NULL,
plan_mode chat_plan_mode,
client_type chat_client_type DEFAULT 'api'::chat_client_type NOT NULL
client_type chat_client_type DEFAULT 'api'::chat_client_type NOT NULL,
CONSTRAINT chats_pin_order_archived_check CHECK (((pin_order = 0) OR (archived = false))),
CONSTRAINT chats_pin_order_parent_check CHECK (((pin_order = 0) OR (parent_chat_id IS NULL)))
);
CREATE TABLE connection_logs (