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 22, 10:45 UTC
fix(server): truncated webhook delivery bodies no longer end in a replacement character (#26070)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
MarcoDotIO committed
Oct 30, 2026 at 17:17 UTC
91c7c4703d12ddc89c94930d15b291fa6d083b45
2 files changed
+31
-1
apps/server/src/scheduledTasks/ScheduledTaskService.ts
+4
-1
@@ -1456,8 +1456,11 @@ export const layer = Layer.effect(
1456
const truncated = request.body.byteLength > WEBHOOK_DELIVERY_LOG_BODY_LIMIT;
1457
return {
1458
truncated,
1459
+ // Streaming decode drops a character the byte limit split, instead of ending in U+FFFD.
1460
body: truncated
1460
- ? new TextDecoder().decode(request.body.subarray(0, WEBHOOK_DELIVERY_LOG_BODY_LIMIT))
1461
+ ? new TextDecoder().decode(request.body.subarray(0, WEBHOOK_DELIVERY_LOG_BODY_LIMIT), {
1462
+ stream: true,
1463
+ })
1464
: request.bodyText,
1465
};
1466
};
apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.ts
+27
@@ -481,6 +481,33 @@ it.effect("keeps credential headers and query values out of the delivery log", (
481
),
482
);
483
484
+it.effect("drops a character split by the delivery log's body limit", () =>
485
+ withService(({ service }) =>
486
+ Effect.gen(function* () {
487
+ const { task } = yield* service.upsert(yield* webhookTaskInput({ enabled: false }));
488
+ const limit = 64 * 1024;
489
+ const euro = new TextEncoder().encode("€");
490
+ const body = new Uint8Array(limit - 1 + euro.length).fill(0x61);
491
+ body.set(euro, limit - 1);
492
+ yield* service.triggerWebhook(
493
+ requestFor(task, { body, bodyText: new TextDecoder().decode(body) }),
494
+ );
495
+ const [summary] = (yield* service.listWebhookDeliveries({
496
+ id: task.id,
497
+ acceptAnyOutcome: true,
498
+ })).deliveries;
499
+ const { delivery } = yield* service.getWebhookDelivery({
500
+ id: task.id,
501
+ deliveryId: summary!.id,
502
+ });
503
+ assert.isTrue(delivery.bodyTruncated);
504
+ assert.equal(delivery.bodyBytes, body.byteLength);
505
+ assert.equal(delivery.body.slice(-3), "aaa");
506
+ assert.equal(delivery.body.length, limit - 1);
507
+ }),
508
+ ),
509
+);
510
+
511
const queuedDeliveryCases = [
512
{
513
change: "paused",