fix(cron): avoid forcing announce mode and clear inherited to on mode change

- UI: only include mode in patch if explicitly set to non-default
- delivery.ts: clear inherited 'to' when job overrides mode, since URL
  semantics differ between announce and webhook modes
This commit is contained in:
Evgeny Zislis
2026-03-02 03:05:40 +02:00
committed by Tak Hoffman
parent 21f0b5b6a2
commit b33a57fba9
2 changed files with 11 additions and 2 deletions

View File

@@ -165,6 +165,11 @@ export function resolveFailureDestination(
accountId = jobAccountId;
}
if (jobMode !== undefined) {
// Mode was explicitly overridden - clear inherited 'to' since URL semantics differ
// between announce (channel recipient) and webhook (HTTP endpoint)
if (globalConfig?.mode !== jobMode) {
to = undefined;
}
mode = jobMode;
}
}

View File

@@ -601,14 +601,18 @@ function buildFailureAlert(form: CronFormState) {
: undefined;
const deliveryMode = form.failureAlertDeliveryMode;
const accountId = form.failureAlertAccountId.trim();
return {
const patch: Record<string, unknown> = {
after: after > 0 ? Math.floor(after) : undefined,
channel: form.failureAlertChannel.trim() || CRON_CHANNEL_LAST,
to: form.failureAlertTo.trim() || undefined,
...(cooldownMs !== undefined ? { cooldownMs } : {}),
...(deliveryMode ? { mode: deliveryMode } : {}),
...(accountId ? { accountId } : {}),
};
// Only include mode if explicitly set to non-default value
if (deliveryMode && deliveryMode !== "announce") {
patch.mode = deliveryMode;
}
return patch;
}
export async function addCronJob(state: CronState) {