decolua/9router · error · Error

data.error || "Authentication failed"

Error message

data.error || "Authentication failed"

What it means

IFlowCookieModal's handleSubmit POSTs the pasted iFlow cookie to its backend endpoint and throws Error(data.error || 'Authentication failed') when the response is not ok, surfacing the server's reason (or the generic fallback) in the modal. It validates credentials by having the backend attempt an authenticated call against iFlow.

Source

Thrown at src/shared/components/IFlowCookieModal.js:36

    if (!cookie.trim()) {
      setError("Please paste your cookie");
      return;
    }

    setLoading(true);
    setError(null);

    try {
      const res = await fetch("/api/oauth/iflow/cookie", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ cookie: cookie.trim() }),
      });

      const data = await res.json();

      if (!res.ok) {
        throw new Error(data.error || "Authentication failed");
      }

      setSuccess(true);
      setTimeout(() => {
        onSuccess?.();
        handleClose();
      }, 1500);
    } catch (err) {
      setError(err.message);
    } finally {
      setLoading(false);
    }
  };

  const handleClose = () => {
    setCookie("");
    setError(null);
    setSuccess(false);

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Re-copy the full cookie value from a fresh logged-in iFlow session (no truncation, no extra characters)
  2. Log in to iFlow again to obtain a new session cookie and retry immediately
  3. Check the backend route logs to see the real upstream rejection reason when the generic message shows
  4. Confirm the cookie belongs to the iFlow environment the router targets

Example fix

// before
throw new Error(data.error || "Authentication failed");
// after
throw new Error(data.error || `iFlow authentication failed (HTTP ${res.status})`);
Defensive patterns

Strategy: try-catch

Validate before calling

const cookie = cookieInput.trim();
if (!cookie || cookie.length < 20) { setError("Paste a valid iFlow session cookie"); return; }

Type guard

function looksLikeCookie(v) { return typeof v === "string" && v.trim().length > 0 && v.includes("="); }

Try / catch

try {
  const res = await fetch(iflowImportEndpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ cookie }) });
  const data = await res.json();
  if (!res.ok) throw new Error(data.error || `Authentication failed (HTTP ${res.status})`);
  setSuccess(true);
} catch (err) {
  setError(err.message);
}

Prevention

When it happens

Trigger: Submitting an invalid/expired/rejected iFlow session cookie, an empty or malformed cookie string that the backend cannot parse, or the backend's upstream validation call failing with a non-2xx response lacking an `error` field.

Common situations: Cookie copied with surrounding text or truncated; iFlow session expired since copying; iFlow upstream unreachable or changed its auth flow; pasting a cookie for the wrong iFlow environment/account.

Understand the failure class

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/97ae0aebb7c13ccf. Report an issue: GitHub.