You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migration 86's queued-input index rejects user messages whose payload is not valid JSON #36894
Written by Claude Opus 5.5 (Claude Code) on behalf of Navid
Migration 86 (086_QueuedTurnInputIndex, from #23420) adds a partial index whose WHERE calls json_extract(payload_json, '$.inputIntent') without a json_valid guard. SQLite evaluates that term on every write of a user_message turn item, so a user message whose payload is not valid JSON can no longer be inserted or updated, and a database that already holds one cannot upgrade past migration 85.
Reproduction with sqlite3 3.54.0, the turn-item table as the projection migration creates it and the index exactly as migration 86 creates it:
On a database that already holds such a user message, the index itself cannot be built:
-- same table, without the index, holding the 'u1' row aboveCREATEINDEXorchestration_v2_projection_turn_items_queued_input_idxON orchestration_v2_projection_turn_items(run_id)
WHERE type ='user_message'AND json_extract(payload_json, '$.inputIntent') ='queued_turn';
-- Error: malformed JSON
Through the server's own migrations on main @ 2137f360e this shows up as Migration "86_QueuedTurnInputIndex" failed … malformed JSON, with the database left at 85. An UPDATE that sets a non-JSON payload on a user message fails the same way.
Assistant messages are unaffected, because the type = 'user_message' term is false before json_extract runs. Migration 89 already guards its expression indexes this way: "json_valid keeps a malformed payload writable, as the other payload indexes do."
Suggested fix: in a new migration, recreate the index with json_valid(payload_json) AND before the json_extract term, and add json_valid(held.payload_json) AND to the two shell-count queries that name it with INDEXED BY; without the matching term SQLite rejects them with "no query solution".
The server normally writes only JSON payloads, so this is defensive.
Activity