PATCH /api/threads/{id}
Update thread title
PATCH
Authentication
Required: JWT Bearer token JWT Claims Extraction (Lines 277-281):Path Parameters
Thread UUIDFormat: Valid GUIDValidation: Route constraint
:guid (Line 270)Request Body
New thread titleValidation (Lines 305-313):Constraints:
- MUST NOT be null
- MUST NOT be empty string
- MUST NOT be whitespace-only
Authorization
Ownership Verification (Lines 289-303):- ONLY thread owner can update title
- No delegation or sharing of update rights
- Admins NOT exempted (no admin check in code)
Side Effects
Database Mutations (Line 315):- UPDATE
threadsSETtitle = {request.Title},updated_at = NOW()WHEREthread_id = {threadId}
- Messages not affected
- Thread visibility not changed
- Ownership not changed
Permissions
Who Can Modify:- Thread owner only
- Other authenticated users
- Unauthenticated users
- Public thread viewers (even if public_sharing enabled)
Edge Cases
- Thread doesn’t exist: 404 (Lines 290-293)
- User is not owner: 403 (Lines 295-303)
- Title is null: 400 (Lines 305-313)
- Title is empty: 400 (Lines 305-313)
- Title is whitespace-only: 400 (Lines 305-313)
- Title same as current: Update proceeds (no change detection)
- Very long title: Not validated by controller (database may truncate or error)
Error Conditions
| Code | HTTP | Cause | Controller Line |
|---|---|---|---|
| N/A | 401 | JWT missing or invalid | Middleware |
| N/A | 401 | User ID claim missing | 283-286 |
INVALID_REQUEST | 400 | Title null/empty/whitespace | 305-313 |
NOT_FOUND | 404 | Thread doesn’t exist | 290-293 |
FORBIDDEN | 403 | Not thread owner | 295-303 |
THREAD_UPDATE_ERROR | 500 | Service exception | 323-331 |
Behavioral Guarantees
Atomicity: Single UPDATE query (atomic) Idempotency: NOT idempotentupdated_attimestamp changes on every call- Even if title unchanged
- Race condition possible if two updates concurrent
- Last write wins (database-dependent)
Validation Order
- User ID from JWT (401 if missing)
- Thread existence (404 if not found)
- Ownership (403 if not owner)
- Title validation (400 if invalid)
- Update execution (500 if fails)
Database Schema Impact
Column Updated:threads.title
Timestamp Updated: threads.updated_at (implicit, service-level)
No Triggers: Controller doesn’t document any database triggers