Significant-Gravitas/AutoGPT · error · Error
Failed to update schedule
Error message
Failed to update schedule
What it means
Default message thrown when PATCH /api/schedules/{id} (Next.js API route proxying the backend schedule update) returns a non-ok response. The code first tries to replace the generic message with data.message or data.detail from the JSON body, then falls back to res.text(), and only keeps 'Failed to update schedule' when the body is unparseable — so seeing the generic text usually means the route returned an empty/HTML error page (e.g. a 500 from Next itself) rather than a JSON backend error.
Source
Thrown at autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedScheduleView/components/EditScheduleModal/useEditScheduleModal.ts:89
if (Object.keys(errorsNow).length > 0) throw new Error("Invalid form");
const cron = humanizeToCron();
const res = await fetch(`/api/schedules/${schedule.id}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name, cron }),
});
if (!res.ok) {
let message = "Failed to update schedule";
try {
const data = await res.json();
message = data?.message || data?.detail || message;
} catch {
try {
message = await res.text();
} catch {}
}
throw new Error(message);
}
return res.json();
},
onSuccess: async () => {
invalidateAllScheduleQueries(queryClient, graphId);
const runsKey = getGetV1ListGraphExecutionsQueryKey(graphId);
await queryClient.invalidateQueries({ queryKey: runsKey });
setIsOpen(false);
},
onError: (error: any) => {
toast({
title: "❌ Failed to update schedule",
description: error?.message || "An unexpected error occurred.",
variant: "destructive",
});
},
});
View on GitHub (pinned to 9c8bb5550f)
Solutions
- Open DevTools → Network → the PATCH request: read the actual response body (message/detail) — the toast usually already shows it; the generic string only appears when the body isn't JSON or text.
- If the backend rejected the cron, verify the generated expression (log humanizeToCron() output) — ensure weekly schedules always include at least one day.
- Re-authenticate if the route returned 401/403.
- If the response is HTML (proxy 500/502), check the Next.js server logs and that the backend container is up.
Example fix
// before
const cron = humanizeToCron(); // weekly with 0 days -> "m h * * *"
// after
if (repeat === "weekly" && selectedDays.length === 0) {
setErrors({ days: "Pick at least one day" });
throw new Error("Invalid form");
} Defensive patterns
Strategy: try-catch
Validate before calling
function isValidCron(cron: string): boolean {
const fields = cron.trim().split(/\s+/);
return fields.length === 5 && fields.every((f) => /^[\d*,\-/]+$/.test(f));
} Type guard
function isScheduleUpdateFailure(err: unknown): boolean {
return err instanceof Error && /Failed to update schedule|schedule/i.test(err.message);
} Try / catch
try {
await mutateAsync();
} catch (error) {
// message already prefers server-provided data.message/data.detail
toast({ title: "Failed to update schedule", description: (error as Error).message, variant: "destructive" });
} Prevention
- Validate the generated cron client-side (five fields, sane ranges) before PATCHing.
- Always attempt to parse error body as JSON then text (as this code does) so users see backend detail, not the generic string.
- Invalidate schedule queries on window focus to avoid editing deleted schedules.
When it happens
Trigger: PATCH /api/schedules/{id} returning 4xx/5xx: invalid cron generated by humanizeToCron (e.g. empty day selection producing '*' conflicts), schedule not found (deleted elsewhere), expired auth on the route, or backend down so the proxy returns HTML 502.
Common situations: Editing a schedule whose graph/schedule was deleted in another tab; backend restart during edit; a cron edge case in humanizeToCron (weekly with no days selected yields '* * * * *'-adjacent output the backend rejects); auth cookie expiry.
Related errors
- Failed to fetch session (status: ${response.status})
- Invalid form
- n8n template not found (${res.status})
- Failed to update email
- Failed to update email
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/61fdce7240ed26c7.
Report an issue: GitHub.