fix(ui): clearing a cron delivery destination in the Control UI silently keeps the old chat (#123171)

Blanking the 'To' field in the Automations delivery editor omitted the
key from the cron.update patch. The Gateway merges delivery patches
by key presence, so the stored destination survived and every future
run kept announcing to the old chat with no error. Send an explicit
null clear on update, exactly like the accountId field one line above
(same bug class fixed there in #105762). Webhook mode is unaffected:
its blank-URL validation rejects the form before submit.
This commit is contained in:
Peter Steinberger
2026-08-13 20:03:06 -07:00
committed by GitHub
parent fdd5fa98e8
commit c66d5d84db
2 changed files with 31 additions and 1 deletions
+28
View File
@@ -680,6 +680,34 @@ describe("cron controller", () => {
});
});
it("sends null delivery.to in cron.update to clear a persisted destination", async () => {
const job = createCronJob({
id: "job-clear-to",
name: "clear to",
delivery: { mode: "announce", channel: "telegram", to: "12345" },
});
const { submit } = createCronSubmitHarness(job.id, {
method: "cron.update",
jobs: [job],
form: {
name: "clear to",
scheduleKind: "cron",
cronExpr: "0 * * * *",
wakeMode: "next-heartbeat",
payloadText: "run",
deliveryMode: "announce",
deliveryTo: " ",
},
});
const { call } = await submit();
expectRecordFields(requireRecord(requestPatch(call).delivery, "delivery"), {
mode: "announce",
to: null,
});
});
it("maps a cron job into editable form fields", () => {
const state = createState();
const job = createCronJob({
+3 -1
View File
@@ -1150,7 +1150,9 @@ export async function addCronJob(state: CronState): Promise<CronSaveResult> {
preserveLastOnUpdate: Boolean(editingJob?.delivery?.channel),
})
: undefined,
to: form.deliveryTo.trim() || undefined,
to:
form.deliveryTo.trim() ||
(selectedDeliveryMode === "announce" && editingJob?.delivery?.to ? null : undefined),
accountId: deliveryAccountId,
bestEffort: form.deliveryBestEffort,
...(form.deliveryThreadId !== undefined ? { threadId: form.deliveryThreadId } : {}),