The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 17:15 UTC
fix(server): migration 64 skips thread payloads that are not valid JSON (#35884)
Julius Marminge committed
Nov 12, 2026 at 19:33 UTC
496856d8d7dadbc0e947b7d80ae40af1042c84fc
2 files changed
+29
apps/server/src/persistence/Migrations/064_CanonicalizeThreadPullRequestLinks.test.ts
+27
@@ -123,9 +123,36 @@ layer("064_CanonicalizeThreadPullRequestLinks", (it) => {
123
'user', ${v1Payload}, '{}', 1)
124
`;
125
126
+ yield* sql`
127
+ INSERT INTO orchestration_v2_projection_threads (
128
+ thread_id, project_id, title, default_provider, runtime_mode, interaction_mode,
129
+ created_at, updated_at, payload_json
130
+ ) VALUES (
131
+ 'damaged', 'project-1', 'damaged', 'codex', 'full-access', 'default',
132
+ ${updatedAt}, ${updatedAt}, ''
133
+ )
134
+ `;
135
+ yield* sql`
136
+ INSERT INTO orchestration_events (
137
+ event_id, aggregate_kind, stream_id, stream_version, event_type, occurred_at,
138
+ actor_kind, payload_json, metadata_json, application_event_version
139
+ ) VALUES ('event:damaged', 'thread', 'damaged', 0, 'thread.created', ${updatedAt},
140
+ 'user', '', '{}', 2)
141
+ `;
142
+
143
assert.deepEqual(yield* runMigrations({ toMigrationInclusive: 64 }), [
144
[64, "CanonicalizeThreadPullRequestLinks"],
145
]);
146
+ const [damagedThread] = yield* sql<{ readonly payload_json: string }>`
147
+ SELECT payload_json FROM orchestration_v2_projection_threads WHERE thread_id = 'damaged'
148
+ `;
149
+ const [damagedEvent] = yield* sql<{ readonly payload_json: string }>`
150
+ SELECT payload_json FROM orchestration_events WHERE event_id = 'event:damaged'
151
+ `;
152
+ assert.equal(damagedThread?.payload_json, "");
153
+ assert.equal(damagedEvent?.payload_json, "");
154
+ yield* sql`DELETE FROM orchestration_v2_projection_threads WHERE thread_id = 'damaged'`;
155
+ yield* sql`DELETE FROM orchestration_events WHERE event_id = 'event:damaged'`;
156
assert.deepEqual(yield* runMigrations({ toMigrationInclusive: 64 }), []);
157
const rows = yield* sql<{ readonly thread_id: string; readonly payload_json: string }>`
158
SELECT thread_id, payload_json FROM orchestration_v2_projection_threads
apps/server/src/persistence/Migrations/064_CanonicalizeThreadPullRequestLinks.ts
+2
@@ -34,6 +34,7 @@ export default Effect.gen(function* () {
34
updated_at
35
FROM orchestration_v2_projection_threads
36
WHERE thread_id > ${afterThreadId}
37
+ AND json_valid(payload_json)
38
AND json_type(payload_json, '$.pullRequests') IS NULL
39
AND json_type(payload_json, '$.linkedPullRequest') = 'object'
40
ORDER BY thread_id
@@ -65,6 +66,7 @@ export default Effect.gen(function* () {
66
WHERE sequence > ${afterSequence}
67
AND application_event_version = 2 AND aggregate_kind = 'thread'
68
AND event_type LIKE 'thread.%'
69
+ AND json_valid(payload_json)
70
AND json_type(payload_json, '$.pullRequests') IS NULL
71
AND json_type(payload_json, '$.linkedPullRequest') = 'object'
72
ORDER BY sequence