fix: carry a zombie job's scopes into its completion

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FHGE3ynoAu6yrgeg4kLwL
This commit is contained in:
Ruben Fiszel
2026-10-02 20:34:12 +02:00
co-authored by Claude Opus 5.5
parent 5ac15db691
commit c770c5a7fc
+14 -1
View File
@@ -6198,10 +6198,23 @@ async fn handle_zombie_jobs(db: &Pool<Postgres>, base_internal_url: &str, node_n
);
let memory_peak = job.memory_peak.unwrap_or(0);
let (_, killpill_rx_never_used) = KillpillSender::new(1);
// Read while the job is still queued: a re-run (perpetual, retry) takes its cap from
// here once the `job_perms` row is swept after completion.
let job_token_scopes = sqlx::query_scalar!(
"SELECT job_token_scopes FROM job_perms WHERE job_id = $1",
job.id
)
.fetch_optional(db)
.await
.ok()
.flatten()
.flatten();
let mut completed = windmill_queue::MiniCompletedJob::from(job);
completed.job_token_scopes = job_token_scopes;
let _ = handle_job_error(
db,
&client,
&windmill_queue::MiniCompletedJob::from(job),
&completed,
memory_peak,
None,
error::Error::ExecutionErr(error_message.clone()),