diff --git a/src/cron/service/jobs.ts b/src/cron/service/jobs.ts index 542ba81053d..4ba6e709a8c 100644 --- a/src/cron/service/jobs.ts +++ b/src/cron/service/jobs.ts @@ -231,7 +231,20 @@ function assertFailureDestinationSupport(job: Pick j.id === id); + // Exact match first + let job = state.store?.jobs.find((j) => j.id === id); + if (!job) { + // Prefix match (like git short hashes) + const matches = state.store?.jobs.filter((j) => j.id.startsWith(id)) ?? []; + if (matches.length === 1) { + job = matches[0]; + } else if (matches.length > 1) { + const ids = matches.map((j) => j.id).join(", "); + throw new Error( + `ambiguous cron job id prefix "${id}" matches ${matches.length} jobs: ${ids}`, + ); + } + } if (!job) { throw new Error(`unknown cron job id: ${id}`); }