{"record":{"id":"c713a6d8047a51a9","repo":"decolua/9router","slug":"data-error-import-failed-c713a6","errorCode":null,"errorMessage":"data.error || \"Import failed\"","messagePattern":"data\\.error \\|\\| \"Import failed\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/components/KiroAuthModal.js","lineNumber":97,"sourceCode":"    }\n\n    setImporting(true);\n    setError(null);\n\n    try {\n      const res = await fetch(\"/api/oauth/kiro/import\", {\n        method: \"POST\",\n        headers: { \"Content-Type\": \"application/json\" },\n        body: JSON.stringify({\n          refreshToken: refreshToken.trim(),\n          ...(idcCredentials || {}),\n        }),\n      });\n\n      const data = await res.json();\n\n      if (!res.ok) {\n        throw new Error(data.error || \"Import failed\");\n      }\n\n      // Success - notify parent to refresh connections\n      onMethodSelect(\"import\");\n    } catch (err) {\n      setError(err.message);\n    } finally {\n      setImporting(false);\n    }\n  };\n\n  const handleImportCliProxyJson = async () => {\n    if (!cliProxyJson.trim()) {\n      setError(\"Please paste CLIProxyAPI auth JSON\");\n      return;\n    }\n\n    setImporting(true);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/shared/components/KiroAuthModal.js#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nthrow new Error(data.error || \"Import failed\");\n// after\nthrow new Error(data.error || `Kiro token import failed (HTTP ${res.status})`);","handlingStrategy":"validation","validationCode":"let payload;\ntry { payload = JSON.parse(tokenInput.trim()); }\ncatch { setError(\"Token must be valid JSON\"); return; }\nif (!payload || typeof payload !== \"object\") { setError(\"Unexpected token format\"); return; }","typeGuard":"function isTokenObject(v) { return typeof v === \"object\" && v !== null && !Array.isArray(v); }","tryCatchPattern":"try {\n  const res = await fetch(kiroImportEndpoint, { method: \"POST\", headers: { \"Content-Type\": \"application/json\" }, body: JSON.stringify({ token: tokenInput.trim() }) });\n  const data = await res.json();\n  if (!res.ok) throw new Error(data.error || `Import failed (HTTP ${res.status})`);\n  onMethodSelect(\"import\");\n} catch (err) {\n  setError(err.message);\n}","preventionTips":["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"],"tags":["auth","kiro","token","import"],"backgroundTag":"token-import-failed","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}