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

  1. 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.
  2. If the backend rejected the cron, verify the generated expression (log humanizeToCron() output) — ensure weekly schedules always include at least one day.
  3. Re-authenticate if the route returned 401/403.
  4. 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

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


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/61fdce7240ed26c7. Report an issue: GitHub.