decolua/9router · error · Error
data.error || "CLIProxyAPI import failed"
Error message
data.error || "CLIProxyAPI import failed"
What it means
KiroAuthModal's handleImportCliProxyJson POSTs CLIProxyAPI config JSON to its dedicated import endpoint and throws Error(data.error || 'CLIProxyAPI import failed') on non-ok responses. The backend parses the CLIProxyAPI JSON and extracts Kiro credentials; failures (bad JSON, unrecognized config, missing credential fields) surface here, with the generic fallback when no `error` field is returned.
Source
Thrown at src/shared/components/KiroAuthModal.js:128
if (!cliProxyJson.trim()) {
setError("Please paste CLIProxyAPI auth JSON");
return;
}
setImporting(true);
setError(null);
try {
const res = await fetch("/api/oauth/kiro/import-cli-proxy", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ json: cliProxyJson.trim() }),
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.error || "CLIProxyAPI import failed");
}
onMethodSelect("import-cli-proxy");
} catch (err) {
setError(err.message);
} finally {
setImporting(false);
}
};
const handleIdcContinue = () => {
if (!idcStartUrl.trim()) {
setError("Please enter your IDC start URL");
return;
}
onMethodSelect("idc", { startUrl: idcStartUrl.trim(), region: idcRegion });
};
View on GitHub (pinned to 90b52e06ff)
Solutions
- Validate the pasted JSON parses (e.g. JSON.parse in console) and is the actual CLIProxyAPI config file
- Confirm the config contains the Kiro credential section the importer expects; strip markdown fences/whitespace
- Check backend logs for the parse/validation error when the generic message shows
- Fall back to the manual token import method in the modal if the CLIProxyAPI JSON is outdated
Example fix
// before
throw new Error(data.error || "CLIProxyAPI import failed");
// after
throw new Error(data.error || `CLIProxyAPI import failed (HTTP ${res.status})`); Defensive patterns
Strategy: validation
Validate before calling
let cfg;
try { cfg = JSON.parse(cliProxyJson.replace(/^```(json)?|```$/g, "").trim()); }
catch { setError("Not valid JSON"); return; }
if (!cfg || typeof cfg !== "object") { setError("Not a CLIProxyAPI config"); return; } Type guard
function isCliProxyConfig(v) { return typeof v === "object" && v !== null && !Array.isArray(v); } Try / catch
try {
const res = await fetch(cliProxyImportEndpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ json: cliProxyJson.trim() }) });
const data = await res.json();
if (!res.ok) throw new Error(data.error || `CLIProxyAPI import failed (HTTP ${res.status})`);
onMethodSelect("import-cli-proxy");
} catch (err) {
setError(err.message);
} Prevention
- Paste the actual CLIProxyAPI config file, not other settings JSON
- Strip markdown code fences and whitespace before submitting
- Keep the importer in sync with CLIProxyAPI schema changes
- Fall back to manual token import when the config lacks Kiro credentials
When it happens
Trigger: Pasting JSON that is not valid CLIProxyAPI config (syntax error or wrong schema), a config without the Kiro credential entries the endpoint expects, or the backend failing for another non-2xx reason without an `error` field.
Common situations: User pastes the wrong file (regular settings JSON instead of CLIProxyAPI's config); CLIProxyAPI version changed its config schema; JSON copied with truncation or markdown fences; config exists but contains no usable Kiro tokens.
Related errors
- data.error || "Import failed"
- data.error || "Import failed"
- Cursor AgentService endpoint is not configured
- Kiro tool_use stop reason did not include a complete tool ca
- Kiro toolUseEvent is empty
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/74002c63f3243cfe.
Report an issue: GitHub.