{"record":{"id":"97ae0aebb7c13ccf","repo":"decolua/9router","slug":"data-error-authentication-failed-97ae0a","errorCode":null,"errorMessage":"data.error || \"Authentication failed\"","messagePattern":"data\\.error \\|\\| \"Authentication failed\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/components/IFlowCookieModal.js","lineNumber":36,"sourceCode":"    if (!cookie.trim()) {\n      setError(\"Please paste your cookie\");\n      return;\n    }\n\n    setLoading(true);\n    setError(null);\n\n    try {\n      const res = await fetch(\"/api/oauth/iflow/cookie\", {\n        method: \"POST\",\n        headers: { \"Content-Type\": \"application/json\" },\n        body: JSON.stringify({ cookie: cookie.trim() }),\n      });\n\n      const data = await res.json();\n\n      if (!res.ok) {\n        throw new Error(data.error || \"Authentication failed\");\n      }\n\n      setSuccess(true);\n      setTimeout(() => {\n        onSuccess?.();\n        handleClose();\n      }, 1500);\n    } catch (err) {\n      setError(err.message);\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  const handleClose = () => {\n    setCookie(\"\");\n    setError(null);\n    setSuccess(false);","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/shared/components/IFlowCookieModal.js#L18-L54","documentation":"IFlowCookieModal's handleSubmit POSTs the pasted iFlow cookie to its backend endpoint and throws Error(data.error || 'Authentication failed') when the response is not ok, surfacing the server's reason (or the generic fallback) in the modal. It validates credentials by having the backend attempt an authenticated call against iFlow.","triggerScenarios":"Submitting an invalid/expired/rejected iFlow session cookie, an empty or malformed cookie string that the backend cannot parse, or the backend's upstream validation call failing with a non-2xx response lacking an `error` field.","commonSituations":"Cookie copied with surrounding text or truncated; iFlow session expired since copying; iFlow upstream unreachable or changed its auth flow; pasting a cookie for the wrong iFlow environment/account.","solutions":["Re-copy the full cookie value from a fresh logged-in iFlow session (no truncation, no extra characters)","Log in to iFlow again to obtain a new session cookie and retry immediately","Check the backend route logs to see the real upstream rejection reason when the generic message shows","Confirm the cookie belongs to the iFlow environment the router targets"],"exampleFix":"// before\nthrow new Error(data.error || \"Authentication failed\");\n// after\nthrow new Error(data.error || `iFlow authentication failed (HTTP ${res.status})`);","handlingStrategy":"try-catch","validationCode":"const cookie = cookieInput.trim();\nif (!cookie || cookie.length < 20) { setError(\"Paste a valid iFlow session cookie\"); return; }","typeGuard":"function looksLikeCookie(v) { return typeof v === \"string\" && v.trim().length > 0 && v.includes(\"=\"); }","tryCatchPattern":"try {\n  const res = await fetch(iflowImportEndpoint, { method: \"POST\", headers: { \"Content-Type\": \"application/json\" }, body: JSON.stringify({ cookie }) });\n  const data = await res.json();\n  if (!res.ok) throw new Error(data.error || `Authentication failed (HTTP ${res.status})`);\n  setSuccess(true);\n} catch (err) {\n  setError(err.message);\n}","preventionTips":["Copy the entire cookie header value, not just one name=value pair","Re-login to iFlow to get a fresh cookie before each import attempt","Confirm the cookie matches the iFlow environment being targeted","Watch for iFlow auth flow changes; keep the backend validator updated"],"tags":["auth","cookie","iflow"],"backgroundTag":"cookie-authentication-failed","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}