Merge 770099e277c89bb347c6dc32b34a0500da902ee6 into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
Andrew D'Amelio 2026-03-21 04:32:09 +01:00 committed by GitHub
commit 1cab2ac704
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -231,7 +231,20 @@ function assertFailureDestinationSupport(job: Pick<CronJob, "sessionTarget" | "d
}
export function findJobOrThrow(state: CronServiceState, id: string) {
const job = state.store?.jobs.find((j) => 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}`);
}