{"record":{"id":"7c6127616f949135","repo":"infiniflow/ragflow","slug":"invalid-channel-name-channel","errorCode":null,"errorMessage":"Invalid channel name: {channel}","messagePattern":"Invalid channel name: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":302,"severity":"error","filePath":"api/apps/restful_apis/user_api.py","lineNumber":187,"sourceCode":"        raise ValueError(f\"Invalid channel name: {channel}\")\n    auth_cli = get_auth_client(channel_config)\n\n    state = get_uuid()\n    session[\"oauth_state\"] = state\n    auth_url = auth_cli.get_authorization_url(state)\n    logging.info(\"OAuth login initiated: channel='%s', state='%s'\", channel, state)\n    return redirect(auth_url)\n\n\n@manager.route(\"/auth/oauth/<channel>/callback\", methods=[\"GET\"])  # noqa: F821\nasync def oauth_callback(channel):\n    \"\"\"\n    Handle the OAuth/OIDC callback for various channels dynamically.\n    \"\"\"\n    try:\n        channel_config = settings.OAUTH_CONFIG.get(channel)\n        if not channel_config:\n            raise ValueError(f\"Invalid channel name: {channel}\")\n        auth_cli = get_auth_client(channel_config)\n\n        # Check the state\n        state = request.args.get(\"state\")\n        if not state or state != session.get(\"oauth_state\"):\n            return redirect(\"/?error=invalid_state\")\n        session.pop(\"oauth_state\", None)\n\n        # Obtain the authorization code\n        code = request.args.get(\"code\")\n        if not code:\n            return redirect(\"/?error=missing_code\")\n\n        # Exchange authorization code for access token\n        if hasattr(auth_cli, \"async_exchange_code_for_token\"):\n            token_info = await auth_cli.async_exchange_code_for_token(code)\n        else:\n            token_info = auth_cli.exchange_code_for_token(code)","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/apps/restful_apis/user_api.py#L169-L205","documentation":"Raised by the OAuth callback route GET /auth/oauth/<channel>/callback when the channel has no entry in settings.OAUTH_CONFIG — the provider that initiated the flow is not (or no longer) configured by the time the provider redirects back. Distinct from invalid_state/missing_code redirects: this fails provider resolution itself.","triggerScenarios":"Provider redirects to /auth/oauth/<channel>/callback with a channel name not in OAUTH_CONFIG — e.g. config changed between login start and callback, the callback URL registered with the provider uses a different channel key, or a stale/misrouted redirect.","commonSituations":"Editing OAuth settings while a flow is in flight, registering the callback URL in Google/GitHub with a misspelled channel, or deployments where the callback host routes to an instance with different config.","solutions":["Ensure the channel key in OAUTH_CONFIG matches the channel segment of the callback URL registered at the provider.","Redo the login flow from scratch after config changes (old states/sessions are invalid anyway).","Check the provider's authorized redirect URI exactly matches /api/v1/auth/oauth/<channel>/callback.","Restart the API server after editing OAuth settings so OAUTH_CONFIG reloads."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from api import settings\n\ndef callback_configured(channel: str) -> bool:\n    return channel in (settings.OAUTH_CONFIG or {})\n\n# before sending the user to the provider:\nassert callback_configured(channel), f\"callback for '{channel}' will fail - provider not configured\"","typeGuard":null,"tryCatchPattern":"try:\n    result = await handle_oauth_callback(channel, request.args)\nexcept ValueError as e:\n    if \"Invalid channel name\" in str(e):\n        return redirect(\"/?error=unconfigured_channel\")\n    raise","preventionTips":["Register the provider callback URL exactly as /api/v1/auth/oauth/<channel>/callback with the configured key.","Restart the API after OAuth config changes; do not run flows across restarts.","Keep provider key names stable between environments."],"tags":["auth","oauth","callback","configuration"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}