Skip to content

Commit acfc208

Browse files
fix(server): migration 64 skips thread payloads that are not valid JSON
An empty or damaged payload_json on a thread projection or a V2 thread event made json_type raise 'malformed JSON', aborting migration 64 and server startup. Guard both queries with json_valid, as migration 77 does. Fixes #35864 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0bdbbeb commit acfc208

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎apps/server/src/persistence/Migrations/064_CanonicalizeThreadPullRequestLinks.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default Effect.gen(function* () {
3434
updated_at
3535
FROM orchestration_v2_projection_threads
3636
WHERE thread_id > ${afterThreadId}
37+
AND json_valid(payload_json)
3738
AND json_type(payload_json, '$.pullRequests') IS NULL
3839
AND json_type(payload_json, '$.linkedPullRequest') = 'object'
3940
ORDER BY thread_id
@@ -65,6 +66,7 @@ export default Effect.gen(function* () {
6566
WHERE sequence > ${afterSequence}
6667
AND application_event_version = 2 AND aggregate_kind = 'thread'
6768
AND event_type LIKE 'thread.%'
69+
AND json_valid(payload_json)
6870
AND json_type(payload_json, '$.pullRequests') IS NULL
6971
AND json_type(payload_json, '$.linkedPullRequest') = 'object'
7072
ORDER BY sequence

0 commit comments

Comments
 (0)