fix(cron): preserve explicit to on mode override and always include mode in UI patches

- delivery.ts: preserve job-level explicit 'to' when overriding mode
- UI: always include mode in failureAlert patch so users can switch between announce/webhook
This commit is contained in:
Evgeny Zislis
2026-03-02 03:21:21 +02:00
committed by Tak Hoffman
parent b33a57fba9
commit 62f71fa401
2 changed files with 7 additions and 3 deletions

View File

@@ -154,6 +154,9 @@ export function resolveFailureDestination(
const jobAccountId = normalizeAccountId(jobFailureDest.accountId);
const jobMode = normalizeFailureMode(jobFailureDest.mode);
// Track if 'to' was explicitly set at job level
const jobToExplicit = "to" in jobFailureDest && jobFailureDest.to !== undefined;
// Only override if explicitly set (not undefined)
if (jobChannel !== undefined) {
channel = jobChannel;
@@ -167,7 +170,8 @@ export function resolveFailureDestination(
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) {
// But preserve explicit 'to' that was set at job level
if (!jobToExplicit && globalConfig?.mode !== jobMode) {
to = undefined;
}
mode = jobMode;

View File

@@ -608,8 +608,8 @@ function buildFailureAlert(form: CronFormState) {
...(cooldownMs !== undefined ? { cooldownMs } : {}),
...(accountId ? { accountId } : {}),
};
// Only include mode if explicitly set to non-default value
if (deliveryMode && deliveryMode !== "announce") {
// Always include mode so users can switch between webhook/announce
if (deliveryMode) {
patch.mode = deliveryMode;
}
return patch;