fix(cancel-poll): use ctx.authToken instead of process.env for cancel polling

The cancel poll was sending empty Authorization headers because
PAPERCLIP_API_KEY is not set on the Paperclip server pod. Use the
per-run authToken from ctx instead, which is the JWT issued by Paperclip
for this execution. PAPERCLIP_DEV_API_KEY still overrides for dev instances.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 07:11:47 -04:00
parent 5e67a4dd3b
commit 985d55e125
3 changed files with 44 additions and 14 deletions
+3 -3
View File
@@ -569,9 +569,9 @@ async function streamAndAwaitJob(
await new Promise<void>((resolve) => setTimeout(resolve, KEEPALIVE_INTERVAL_MS));
if (logStopSignal.stopped || cancelSignal.cancelled) break;
try {
// Prefer PAPERCLIP_DEV_API_KEY if set (allows dev instance key to be
// distinct from the main-instance run JWT in PAPERCLIP_API_KEY).
const apiKey = process.env.PAPERCLIP_DEV_API_KEY ?? process.env.PAPERCLIP_API_KEY ?? "";
// Prefer PAPERCLIP_DEV_API_KEY if set (dev override), otherwise use
// the per-run authToken issued by Paperclip for this execution.
const apiKey = process.env.PAPERCLIP_DEV_API_KEY ?? ctx.authToken ?? "";
const resp = await fetch(`${apiUrl}/api/issues/${issueId}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});