fix: handle both jobId and id in cron list to prevent crash

Fixes #4373

The printCronList function was crashing when accessing job.id because
the Gateway API may return jobId instead of id depending on the version
or context. This adds a defensive check that tries jobId first, then
falls back to id, then to empty string.

Changes:
- src/cli/cron-cli/shared.ts: Extract id with type assertion to handle
  both jobId and id properties, preventing TypeError on .padEnd()
This commit is contained in:
spiceoogway 2026-01-30 00:42:04 -05:00
parent 080a4dbd86
commit 807624a812

View File

@ -141,7 +141,9 @@ export function printCronList(jobs: CronJob[], runtime = defaultRuntime) {
const now = Date.now();
for (const job of jobs) {
const idLabel = pad(job.id, CRON_ID_PAD);
// Gateway may return either 'id' or 'jobId' depending on API version
const id = (job as CronJob & { jobId?: string }).jobId ?? job.id ?? "";
const idLabel = pad(id, CRON_ID_PAD);
const nameLabel = pad(truncate(job.name, CRON_NAME_PAD), CRON_NAME_PAD);
const scheduleLabel = pad(
truncate(formatSchedule(job.schedule), CRON_SCHEDULE_PAD),