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
- Re-extract the token from a current, logged-in Kiro client and paste the complete JSON
- Verify the token JSON shape matches what the import endpoint expects (field names/keys)
- Check the backend route logs for the underlying rejection when the fallback message appears
- 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
- Extract tokens with a current Kiro client version; formats drift between releases
- Paste the complete token JSON — partial copies are the top cause of failures
- Validate JSON locally before submitting
- Check backend logs whenever the generic fallback message appears
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
- data.error || "Import failed"
- data.error || "CLIProxyAPI import failed"
- cosy: auth token is empty
- Cursor AgentService endpoint is not configured
- Kiro tool_use stop reason did not include a complete tool ca
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/c713a6d8047a51a9.
Report an issue: GitHub.