{"record":{"id":"fd8f3e8c0ee10310","repo":"decolua/9router","slug":"data-error","errorCode":null,"errorMessage":"data.error","messagePattern":"data\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/components/KiroSocialOAuthModal.js","lineNumber":39,"sourceCode":"  // Reset auto-open guard when modal closes so it can re-open next session.\n  useEffect(() => {\n    if (!isOpen) openedRef.current = false;\n  }, [isOpen]);\n\n  // Initialize auth flow\n  useEffect(() => {\n    if (!isOpen || !provider) return;\n\n    const initAuth = async () => {\n      try {\n        setError(null);\n        setStep(\"loading\");\n\n        const res = await fetch(`/api/oauth/kiro/social-authorize?provider=${provider}`);\n        const data = await res.json();\n\n        if (!res.ok) {\n          throw new Error(data.error);\n        }\n\n        setAuthData(data);\n        setAuthUrl(data.authUrl);\n        setStep(\"input\");\n\n        // Auto-open browser once per modal session.\n        if (!openedRef.current) {\n          openedRef.current = true;\n          window.open(data.authUrl, \"_blank\");\n        }\n      } catch (err) {\n        setError(err.message);\n        setStep(\"error\");\n      }\n    };\n\n    initAuth();","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/shared/components/KiroSocialOAuthModal.js#L21-L57","documentation":"initAuth in KiroSocialOAuthModal throws this when GET /api/oauth/kiro/social-authorize?provider=<provider> responds with a non-2xx status. The message is exactly `data.error` — if the error body omits an `error` field, the thrown Error's message is literally `undefined`, which is a known rough edge of this pattern. On success the route returns { authUrl, codeVerifier, ... } used for the PKCE social login flow.","triggerScenarios":"The social-authorize route rejects the request: unsupported `provider` query value, the Kiro social OAuth endpoint is unreachable so the route can't build an authUrl, or the route returns 4xx/5xx with { error }.","commonSituations":"Developer opens the modal with a provider slug the backend doesn't recognize; Kiro's social IdP is down or blocked by network/firewall; server running an older build without the social-authorize route; session/auth middleware on the dashboard rejects the request.","solutions":["Check the response body in the browser Network tab — the route's `error` field states the real cause (e.g. unsupported provider).","Verify the `provider` value passed to KiroSocialOAuthModal matches one supported by the social-authorize route.","Confirm the server can reach Kiro's social OAuth endpoint (DNS/proxy/firewall) — authorize-URL generation requires it.","Update to a build that includes /api/oauth/kiro/social-authorize; a 404 means the route is missing."],"exampleFix":"// before\nif (!res.ok) {\n  throw new Error(data.error);\n}\n// after\nif (!res.ok) {\n  throw new Error(data?.error || `Social auth init failed (HTTP ${res.status})`);\n}","handlingStrategy":"try-catch","validationCode":"// validate the provider slug before init\nconst SUPPORTED = [\"google\", \"github\"]; // per backend route\nif (!SUPPORTED.includes(provider)) {\n  throw new Error(`Unsupported social provider: ${provider}`);\n}","typeGuard":"function isAuthInitResponse(data) {\n  return typeof data === \"object\" && data !== null && typeof data.authUrl === \"string\" && typeof data.codeVerifier === \"string\";\n}","tryCatchPattern":"try {\n  const res = await fetch(`/api/oauth/kiro/social-authorize?provider=${encodeURIComponent(provider)}`);\n  const data = await res.json().catch(() => ({}));\n  if (!res.ok) throw new Error(data.error || `Social auth init failed (HTTP ${res.status})`);\n} catch (err) {\n  setError(err.message);\n  setStep(\"error\");\n}","preventionTips":["Only pass provider slugs the backend route supports.","URL-encode query params.","Guard against `undefined` messages by always providing an HTTP-status fallback.","Pre-check network reachability if running behind restrictive proxies."],"tags":["oauth","network","kiro","pkce"],"backgroundTag":"oauth-authorization-request-failed","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}