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): HEAD webhook probes no longer start agent runs (#25291)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Oct 30, 2026 at 16:12 UTC
40b435377e664184b4f84cac435a4c069239b197
2 files changed
+42
-2
apps/server/src/scheduledTasks/webhookRoute.test.ts
+26
@@ -249,6 +249,32 @@ describe("webhook route", () => {
249
}
250
});
251
252
+ it("refuses HEAD probes without triggering the hook", async () => {
253
+ let calls = 0;
254
+ const { handler, dispose } = handlerFor(() => {
255
+ calls += 1;
256
+ return Effect.succeed({
257
+ _tag: "accepted",
258
+ deliveryId: ScheduledTaskWebhookDeliveryId.make("delivery:1"),
259
+ outcome: "accepted",
260
+ });
261
+ });
262
+ try {
263
+ const response = await handler(
264
+ new Request("http://env.local/api/hooks/id/tok", { method: "HEAD" }),
265
+ );
266
+ expect(response.status).toBe(405);
267
+ expect(response.headers.get("allow")).toBe("GET, POST, PUT, PATCH");
268
+ expect(response.headers.get("x-t3-hook-outcome")).toBe("method_not_allowed");
269
+ expect(calls).toBe(0);
270
+ const get = await handler(new Request("http://env.local/api/hooks/id/tok"));
271
+ expect(get.status).toBe(202);
272
+ expect(calls).toBe(1);
273
+ } finally {
274
+ await dispose();
275
+ }
276
+ });
277
+
278
it("hides service failures and defects behind a fixed 500", async () => {
279
const failures = [
280
Effect.fail(new ScheduledTaskError({ message: "database locked" })),
apps/server/src/scheduledTasks/webhookRoute.ts
+16
-2
@@ -20,8 +20,16 @@ export const WEBHOOK_MAX_BODY_BYTES = 1024 * 1024;
20
// The relay records this outcome header.
21
const WEBHOOK_OUTCOME_HEADER = "x-t3-hook-outcome";
22
23
-const json = (status: number, body: Record<string, string>, outcome: string) =>
24
- HttpServerResponse.jsonUnsafe(body, { status, headers: { [WEBHOOK_OUTCOME_HEADER]: outcome } });
23
+const json = (
24
+ status: number,
25
+ body: Record<string, string>,
26
+ outcome: string,
27
+ headers?: Record<string, string>,
28
+) =>
29
+ HttpServerResponse.jsonUnsafe(body, {
30
+ status,
31
+ headers: { ...headers, [WEBHOOK_OUTCOME_HEADER]: outcome },
32
+ });
33
34
export const layer = HttpApiBuilder.group(
35
EnvironmentHttpApi,
@@ -41,6 +49,12 @@ export const layer = HttpApiBuilder.group(
49
readonly params: { readonly hookId: string; readonly token: string };
50
readonly request: HttpServerRequest.HttpServerRequest;
51
}) {
52
+ // The router answers HEAD with the GET route; link checkers probe with HEAD.
53
+ if (request.method === "HEAD") {
54
+ return json(405, { error: "method_not_allowed" }, "method_not_allowed", {
55
+ allow: "GET, POST, PUT, PATCH",
56
+ });
57
+ }
58
const contentLength = Number(request.headers["content-length"] ?? "0");
59
if (!Number.isFinite(contentLength) || contentLength > WEBHOOK_MAX_BODY_BYTES) {
60
return json(413, { error: "body_too_large" }, "body_too_large");