decolua/9router · error · Error

data.error || "Import failed"

Error message

data.error || "Import failed"

What it means

KiroAuthModal's handleImportToken POSTs an imported Kiro token to its import endpoint and throws Error(data.error || 'Import failed') on non-ok responses, rendering the message in the modal. Like the other auth modals, the generic fallback shows when the API fails without returning an `error` field.

Source

Thrown at src/shared/components/KiroAuthModal.js:97

    }

    setImporting(true);
    setError(null);

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

      const data = await res.json();

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

      // Success - notify parent to refresh connections
      onMethodSelect("import");
    } catch (err) {
      setError(err.message);
    } finally {
      setImporting(false);
    }
  };

  const handleImportCliProxyJson = async () => {
    if (!cliProxyJson.trim()) {
      setError("Please paste CLIProxyAPI auth JSON");
      return;
    }

    setImporting(true);

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Re-extract the token from a current, logged-in Kiro client and paste the complete JSON
  2. Verify the token JSON shape matches what the import endpoint expects (field names/keys)
  3. Check the backend route logs for the underlying rejection when the fallback message appears
  4. Refresh Kiro credentials by logging in again, since refresh tokens expire

Example fix

// before
throw new Error(data.error || "Import failed");
// after
throw new Error(data.error || `Kiro token import failed (HTTP ${res.status})`);
Defensive patterns

Strategy: validation

Validate before calling

let payload;
try { payload = JSON.parse(tokenInput.trim()); }
catch { setError("Token must be valid JSON"); return; }
if (!payload || typeof payload !== "object") { setError("Unexpected token format"); return; }

Type guard

function isTokenObject(v) { return typeof v === "object" && v !== null && !Array.isArray(v); }

Try / catch

try {
  const res = await fetch(kiroImportEndpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token: tokenInput.trim() }) });
  const data = await res.json();
  if (!res.ok) throw new Error(data.error || `Import failed (HTTP ${res.status})`);
  onMethodSelect("import");
} catch (err) {
  setError(err.message);
}

Prevention

When it happens

Trigger: Submitting an invalid/expired Kiro token or refresh-token bundle, a JSON payload the backend cannot parse, or any non-2xx backend response (upstream Kiro validation failure) whose body has no `error` field.

Common situations: Token extracted from an outdated Kiro client version (format changed); expired refresh token; pasting only part of the token JSON; backend cannot reach AWS/Kiro auth endpoints.

Related errors


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