GET /api/threads/{id}/messages
Retrieve all messages in a thread
GET
Authentication
Conditional (Line 198):[AllowAnonymous]
Follows same access rules as GET /api/threads/
Path Parameters
Thread UUIDFormat: Valid GUIDValidation: Route constraint
:guid (Line 197)Response
Array of message objects
Authorization Logic
Identical to GET /api/threads/ (Lines 203-249):Access Control Matrix
| Flag | Visibility | Auth | Access |
|---|---|---|---|
| ON | public | No | ✅ Allowed |
| ON | unlisted | No | ✅ Allowed |
| ON | private | No | ❌ 401 |
| ON | private | Yes (owner) | ✅ Allowed |
| ON | private | Yes (other) | ❌ 403 |
| OFF | * | No | ❌ 401 |
| OFF | * | Yes (owner) | ✅ Allowed |
| OFF | * | Yes (other) | ❌ 403 |
Side Effects
Database Reads (Lines 204, 216, 251):- SELECT from
threadstable WHEREthread_id = {id} - SELECT from
system_settingstable WHEREkey = 'public_sharing' - SELECT from
thread_messagestable WHEREthread_id = {id}
Permissions
Same as Thread Access:- If user can read thread, user can read messages
- No separate message-level permissions
Edge Cases
- Thread doesn’t exist: 404 (Lines 206-214)
- Thread exists but has zero messages: Returns
{"items": []}(Line 253) - Invalid GUID format: 400 (route constraint)
- Deleted thread: 404 (service returns null for thread)
- Orphaned messages (thread deleted): Cannot occur (thread lookup first)
- Partial message data (model2 null in single-chat): Nullable fields return null
Error Conditions
| Code | HTTP | Cause | Controller Line |
|---|---|---|---|
NOT_FOUND | 404 | Thread doesn’t exist | 206-214 |
UNAUTHORIZED | 401 | Auth required but missing | 230-238 |
FORBIDDEN | 403 | Private thread, wrong user | 240-248 |
MESSAGES_ERROR | 500 | Service exception | 255-263 |
Behavioral Guarantees
Two-Step Verification (Lines 204-249):- Thread existence + access check
- Messages retrieval
- Thread could be deleted between checks (race condition)
- Service behavior on race condition not enforced by server contract
- Returns ALL messages for thread
- No limit parameter
- Could cause performance issues for large threads
Performance Characteristics
Database Queries: 3 queries per request- Thread lookup
- Feature flag lookup
- Messages retrieval
thread_messages.thread_idshould be indexedthreads.thread_idprimary key
Message Schema Details
Single-Chat Mode:model1_id: Populatedmodel2_id: NULLmodel1_response: Populatedmodel2_response: NULLcomparison_id: NULL
model1_id: Populatedmodel2_id: Populatedmodel1_response: Populatedmodel2_response: Populatedcomparison_id: Populated (links tocomparisonstable)
- Can be used with GET /api/arena/model-stats to see vote data
- Links message to arena comparison for voting