{"record":{"id":"693efb494ea8c161","repo":"decolua/9router","slug":"params-error-description-params-error","errorCode":null,"errorMessage":"${params.error_description || params.error}","messagePattern":"\\$\\{params\\.error_description \\|\\| params\\.error\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/services/kimchi.js","lineNumber":75,"sourceCode":"    // Map can't grow unbounded across many logins.\n    result.then((r) => {\n      const s = sessions.get(state);\n      if (!s) return;\n      s.done = true;\n      s.resolved = r;\n      clearTimeout(s.timeout);\n      try { s.close(); } catch { /* already closed */ }\n      setTimeout(() => sessions.delete(state), SESSION_TTL_MS).unref?.();\n    });\n\n    const callbackUrl = `http://127.0.0.1:${port}${KIMCHI_CONFIG.callbackPath}`;\n    const authUrl = buildKimchiAuthUrl(callbackUrl, state);\n    return { authUrl, port, state, result, close };\n  }\n\n  async _handleCallback(params, expectedState) {\n    if (params.error) {\n      throw new Error(params.error_description || params.error);\n    }\n    const candidate = params.state;\n    if (!candidate || candidate !== expectedState) {\n      throw new Error(\"This request isn't valid. Please restart the Kimchi login flow.\");\n    }\n    const token = params.token;\n    if (!token) {\n      throw new Error(\"No token was returned by the Kimchi authentication server\");\n    }\n    const check = await this.validateToken(token);\n    if (!check.valid) {\n      throw new Error(check.error || \"Kimchi token validation failed\");\n    }\n    return { token };\n  }\n\n  async fetchProfile(token) {\n    try {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/lib/oauth/services/kimchi.js#L57-L93","documentation":"Thrown by KimchiService._handleCallback() when the browser callback reports an OAuth-style error: the query string contains an `error` parameter, and the message relays `error_description` (or the bare code). Kimchi's browser login normally delivers a token directly on the callback; an `error` param means the Kimchi web app's login flow rejected or aborted the authentication.","triggerScenarios":"The Kimchi web app redirects to the local callback with ?error=... — user canceled in the Kimchi UI, Kimchi session expired mid-flow, or Kimchi's backend refused the login (invalid credentials, SSO failure, backend outage).","commonSituations":"User closing/canceling the Kimchi login tab; Kimchi account session cookie expired; Kimchi service degradation; the CLI-auth page on the Kimchi web app failing validation and redirecting back with an error code.","solutions":["Read the message — error_description names the exact Kimchi-side reason.","Restart the login flow (startLogin()) and complete the Kimchi browser step without canceling.","Log into the Kimchi web app in the browser first to refresh the session, then retry.","If the error persists for all attempts, check Kimchi service status / web app availability."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const { result } = await kimchiService.startLogin();\n  const outcome = await result; // resolves to { token } or { error }\n  if (outcome.error) throw new Error(outcome.error);\n} catch (err) {\n  if (/denied|cancel|error/i.test(err.message)) {\n    console.log(\"Kimchi login aborted — restart the flow and complete the browser step.\");\n  } else { throw err; }\n}","preventionTips":["Complete the Kimchi browser login without canceling or closing the tab.","Log into the Kimchi web app beforehand so the session is fresh.","Only run one Kimchi login at a time.","Check Kimchi service status if authorization errors repeat across attempts."],"tags":["oauth","authorization","callback","kimchi"],"backgroundTag":"oauth-authorization-error","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}