{"record":{"id":"74002c63f3243cfe","repo":"decolua/9router","slug":"data-error-cliproxyapi-import-failed","errorCode":null,"errorMessage":"data.error || \"CLIProxyAPI import failed\"","messagePattern":"data\\.error \\|\\| \"CLIProxyAPI import failed\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/components/KiroAuthModal.js","lineNumber":128,"sourceCode":"    if (!cliProxyJson.trim()) {\n      setError(\"Please paste CLIProxyAPI auth JSON\");\n      return;\n    }\n\n    setImporting(true);\n    setError(null);\n\n    try {\n      const res = await fetch(\"/api/oauth/kiro/import-cli-proxy\", {\n        method: \"POST\",\n        headers: { \"Content-Type\": \"application/json\" },\n        body: JSON.stringify({ json: cliProxyJson.trim() }),\n      });\n\n      const data = await res.json();\n\n      if (!res.ok) {\n        throw new Error(data.error || \"CLIProxyAPI import failed\");\n      }\n\n      onMethodSelect(\"import-cli-proxy\");\n    } catch (err) {\n      setError(err.message);\n    } finally {\n      setImporting(false);\n    }\n  };\n\n  const handleIdcContinue = () => {\n    if (!idcStartUrl.trim()) {\n      setError(\"Please enter your IDC start URL\");\n      return;\n    }\n    onMethodSelect(\"idc\", { startUrl: idcStartUrl.trim(), region: idcRegion });\n  };\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/shared/components/KiroAuthModal.js#L110-L146","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nthrow new Error(data.error || \"CLIProxyAPI import failed\");\n// after\nthrow new Error(data.error || `CLIProxyAPI import failed (HTTP ${res.status})`);","handlingStrategy":"validation","validationCode":"let cfg;\ntry { cfg = JSON.parse(cliProxyJson.replace(/^```(json)?|```$/g, \"\").trim()); }\ncatch { setError(\"Not valid JSON\"); return; }\nif (!cfg || typeof cfg !== \"object\") { setError(\"Not a CLIProxyAPI config\"); return; }","typeGuard":"function isCliProxyConfig(v) { return typeof v === \"object\" && v !== null && !Array.isArray(v); }","tryCatchPattern":"try {\n  const res = await fetch(cliProxyImportEndpoint, { method: \"POST\", headers: { \"Content-Type\": \"application/json\" }, body: JSON.stringify({ json: cliProxyJson.trim() }) });\n  const data = await res.json();\n  if (!res.ok) throw new Error(data.error || `CLIProxyAPI import failed (HTTP ${res.status})`);\n  onMethodSelect(\"import-cli-proxy\");\n} catch (err) {\n  setError(err.message);\n}","preventionTips":["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"],"tags":["auth","kiro","import","json"],"backgroundTag":"cli-proxy-import-failed","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}