infiniflow/ragflow · error · ValueError
100
100
Error message
Invalid channel name: {channel} What it means
Raised by GET /auth/login/<channel> when the channel is not present in settings.OAUTH_CONFIG, i.e. no OAuth provider is configured under that name. The route dynamically serves any configured provider (google, github, oidc, ...), so unknown or unconfigured names fail here.
Source
Thrown at api/apps/restful_apis/user_api.py:169
for channel, config in settings.OAUTH_CONFIG.items():
channels.append(
{
"channel": channel,
"display_name": config.get("display_name", channel.title()),
"icon": config.get("icon", "sso"),
}
)
return get_json_result(data=channels)
except Exception as e:
logging.exception(e)
return get_json_result(data=[], message=f"Load channels failure, error: {str(e)}", code=RetCode.EXCEPTION_ERROR)
@manager.route("/auth/login/<channel>", methods=["GET"]) # noqa: F821
async def oauth_login(channel):
channel_config = settings.OAUTH_CONFIG.get(channel)
if not channel_config:
raise ValueError(f"Invalid channel name: {channel}")
auth_cli = get_auth_client(channel_config)
state = get_uuid()
session["oauth_state"] = state
auth_url = auth_cli.get_authorization_url(state)
logging.info("OAuth login initiated: channel='%s', state='%s'", channel, state)
return redirect(auth_url)
@manager.route("/auth/oauth/<channel>/callback", methods=["GET"]) # noqa: F821
async def oauth_callback(channel):
"""
Handle the OAuth/OIDC callback for various channels dynamically.
"""
try:
channel_config = settings.OAUTH_CONFIG.get(channel)
if not channel_config:
raise ValueError(f"Invalid channel name: {channel}")View on GitHub (pinned to 554fb1133a)
Solutions
- List configured channels via the channels endpoint (GET /auth/channels) and use one of those names.
- Add the provider under settings.OAUTH_CONFIG with the exact key used in the URL.
- Fix typos in the channel path segment.
- Verify the settings file containing OAUTH_CONFIG is actually loaded by the API server.
Example fix
# before GET /api/v1/auth/login/googl # after GET /api/v1/auth/login/google
Defensive patterns
Strategy: validation
Validate before calling
from api import settings
def is_valid_channel(channel: str) -> bool:
return channel in (settings.OAUTH_CONFIG or {})
assert is_valid_channel(channel), f"channel must be one of {list((settings.OAUTH_CONFIG or {}))}" Type guard
const isValidChannel = (c: string, configured: string[]): c is (typeof configured)[number] => configured.includes(c);
Try / catch
try:
resp = requests.get(f"{base}/api/v1/auth/login/{channel}", allow_redirects=False)
except ValueError as e:
if "Invalid channel" in str(e):
channels = requests.get(f"{base}/api/v1/auth/channels").json()
raise ValueError(f"Pick one of {channels}") from e
raise Prevention
- Render login buttons from the /auth/channels response, never hardcoded lists.
- Automate a config test asserting OAUTH_CONFIG keys match frontend constants.
When it happens
Trigger: Hitting /api/v1/auth/login/slack when only google/github are keys in OAUTH_CONFIG; typos in the channel path; providers configured but under different key names in settings.
Common situations: Frontend links hardcoding a channel the deployment does not enable, env-based OAuth config not loaded (empty OAUTH_CONFIG), or name mismatches between UI and service_conf.yaml oauth section.
Related errors
- Unsupported type: {channel_type}
- Failed to exchange authorization code for token: {e}
- Failed to fetch user info: {e}
- Invalid channel name: {channel}
- Failed to fetch memory detail
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/cc065b5dcb9ec904.
Report an issue: GitHub.