Significant-Gravitas/AutoGPT · error · Error

Authentication error — please sign in again.

Error message

Authentication error — please sign in again.

What it means

Thrown by postFileToBackend in src/lib/direct-upload.ts when getWebSocketToken() returns an error or no token. This helper supplies the Authorization header for direct file uploads to the backend (bypassing the Next.js proxy), so without a valid JWT the upload is aborted before it starts. Functionally identical to the copilot auth error (error 20) — same token source, same failure class — but for upload endpoints.

Source

Thrown at autogpt_platform/frontend/src/lib/direct-upload.ts:78

    variant: "destructive",
  });
  return true;
}

interface DirectUploadArgs {
  path: string;
  file: File;
  searchParams?: Record<string, string>;
}

async function postFileToBackend({
  path,
  file,
  searchParams,
}: DirectUploadArgs): Promise<Response> {
  const { token, error: tokenError } = await getWebSocketToken();
  if (tokenError || !token) {
    throw new Error("Authentication error — please sign in again.");
  }

  const baseURL = new URL(environment.getAGPTServerBaseUrl());
  baseURL.pathname = `${baseURL.pathname.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
  const url = baseURL;
  for (const [key, value] of Object.entries(searchParams ?? {})) {
    url.searchParams.set(key, value);
  }

  const formData = new FormData();
  formData.append("file", file);

  return fetch(url.toString(), {
    method: "POST",
    headers: { Authorization: `Bearer ${token}` },
    body: formData,
    // Guard against a stalled connection leaving the UI stuck "Uploading…".
    // Generous so large (up to 50MB) uploads on slow links aren't cut off.

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Sign in again (reload the app) — simplest and correct for expired sessions.
  2. Verify the getWebSocketToken server action call in DevTools; non-200 there points at Supabase config, not the upload endpoint.
  3. Check NEXT_PUBLIC_SUPABASE_* env vars in frontend/.env for the usual dev drift.
  4. Harden callers to catch this and trigger re-auth/redirect instead of surfacing a raw upload failure.
Defensive patterns

Strategy: try-catch

Validate before calling

import { getWebSocketToken } from "@/lib/auth/actions";

async function assertUploadAuth(): Promise<string> {
  const { token, error } = await getWebSocketToken();
  if (error || !token) throw new Error("Authentication error — please sign in again.");
  return token;
}

Type guard

function isUploadAuthError(err: unknown): boolean {
  return err instanceof Error && err.message.startsWith("Authentication error");
}

Try / catch

try {
  await postFileToBackend({ path, file });
} catch (error) {
  if (isUploadAuthError(error)) {
    window.location.href = "/login"; // no point retrying with a dead session
    return;
  }
  throw error;
}

Prevention

When it happens

Trigger: Uploading a file (block media upload, store thumbnails, etc.) with an expired Supabase session, a missing session cookie, or a failed getWebSocketToken server action (backend/auth misconfiguration or network failure).

Common situations: Long-open builder tab past JWT expiry; signed out in another tab; dev environment with mismatched Supabase config; cookies blocked by browser settings so the server action can't authenticate.

Understand the failure class

Related errors


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