{"record":{"id":"3c21653c2c05fbfd","repo":"decolua/9router","slug":"url-searchparams-get-error-description-error-3c2165","errorCode":null,"errorMessage":"url.searchParams.get(\"error_description\") || errorParam","messagePattern":"url\\.searchParams\\.get\\(\"error_description\"\\) \\|\\| errorParam","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/components/OAuthModal.js","lineNumber":635,"sourceCode":"\n      if (provider === \"xai\" && input && !input.includes(\"://\") && !input.includes(\"?\") && !input.includes(\"code=\")) {\n        await completeXaiManualCode(input);\n        return;\n      }\n\n      if (provider === \"kimchi\" && input && !input.includes(\"://\") && !input.includes(\"?\")) {\n        await exchangeTokens(input, null);\n        return;\n      }\n\n      const url = new URL(input);\n      const code = url.searchParams.get(\"code\");\n      const token = url.searchParams.get(\"token\");\n      const state = url.searchParams.get(\"state\");\n      const errorParam = url.searchParams.get(\"error\");\n\n      if (errorParam) {\n        throw new Error(url.searchParams.get(\"error_description\") || errorParam);\n      }\n\n      if (!code && !token) {\n        throw new Error(\n          provider === \"xai\"\n            ? \"Paste the callback URL or copied xAI code\"\n            : provider === \"kimchi\"\n              ? \"No Kimchi token found in URL\"\n              : \"No authorization code found in URL\"\n        );\n      }\n\n      await exchangeTokens(token || code, state);\n    } catch (err) {\n      setError(err.message);\n      setStep(\"error\");\n    }\n  };","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/shared/components/OAuthModal.js#L617-L653","documentation":"When parsing the manually pasted callback URL, if the URL contains an `error` query parameter the modal throws with the `error_description` (or the bare error code). This is the upstream OAuth provider redirecting back with an authorization error (RFC 6749 §4.1.2.1) instead of a code, and the modal surfaces it verbatim.","triggerScenarios":"Pasting a callback URL like http://localhost:PORT/callback?error=access_denied&error_description=... — the user denied consent at the provider, or the provider rejected the request (invalid_scope, redirect_uri mismatch, client deleted).","commonSituations":"Clicking 'Cancel'/'Deny' on the provider consent screen; account lacks required scopes; provider app misconfigured (redirect_uri/client mismatch); org policies blocking third-party app access.","solutions":["Read the error_description in the URL/exception for the exact provider-side cause","Redo the flow and click Allow/Authorize on the consent screen","If access_denied persists, check org/provider policy for third-party app access","If the cause is invalid_scope or redirect_uri mismatch, fix the provider app configuration in gateway settings"],"exampleFix":"// before\nif (errorParam) {\n  throw new Error(url.searchParams.get(\"error_description\") || errorParam);\n}\n// after\nif (errorParam) {\n  throw new Error(`OAuth provider error (${errorParam}): ${url.searchParams.get(\"error_description\") || \"no description\"}`);\n}","handlingStrategy":"type-guard","validationCode":"const u = new URL(callbackUrl.trim());\nif (u.searchParams.get('error')) {\n  setError(`Provider said: ${u.searchParams.get('error_description') || u.searchParams.get('error')}`);\n  return;\n}","typeGuard":"const isOAuthErrorUrl = (input) => {\n  try { return !!new URL(input).searchParams.get('error'); } catch { return false; }\n};","tryCatchPattern":"try {\n  await handleManualSubmit();\n} catch (e) {\n  if (e.message.includes('access_denied')) { /* advise: click Allow on consent screen */ }\n  else { /* show error_description to user */ }\n}","preventionTips":["Always click Allow/Authorize on the provider consent screen","Check provider app configuration if errors repeat (redirect_uri, scopes)","Inspect the callback URL's error/error_description params before submitting","Verify account/org permissions for third-party app access"],"tags":["oauth","access-denied","consent"],"backgroundTag":"oauth-access-denied","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}