fix: normalize OAuth provider config flags#9135
Conversation
📝 WalkthroughWalkthroughA helper function normalizes OAuth provider configuration values by trimming, lowercasing, and accepting "1" or "true" as enabled. Four OAuth provider enablement flags in instance configuration parsing are updated to use this flexible normalization instead of strict string equality. ChangesConfiguration Parsing Enhancement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/api/plane/license/api/views/instance.py (1)
134-135: ⚡ Quick winConsider applying the same normalization to other boolean configuration values.
For consistency and robustness, the same flexible boolean normalization could be applied to
ENABLE_SIGNUP,DISABLE_WORKSPACE_CREATION,ENABLE_MAGIC_LINK_LOGIN, andENABLE_EMAIL_PASSWORD. These flags currently use strict== "1"comparisons, which means they would face the same issue if configured with boolean-like strings such as "true".♻️ Proposed consistency improvement
- data["enable_signup"] = ENABLE_SIGNUP == "1" - data["is_workspace_creation_disabled"] = DISABLE_WORKSPACE_CREATION == "1" + data["enable_signup"] = _is_config_enabled(ENABLE_SIGNUP) + data["is_workspace_creation_disabled"] = _is_config_enabled(DISABLE_WORKSPACE_CREATION) data["is_google_enabled"] = _is_config_enabled(IS_GOOGLE_ENABLED) data["is_github_enabled"] = _is_config_enabled(IS_GITHUB_ENABLED) data["is_gitlab_enabled"] = _is_config_enabled(IS_GITLAB_ENABLED) data["is_gitea_enabled"] = _is_config_enabled(IS_GITEA_ENABLED) - data["is_magic_login_enabled"] = ENABLE_MAGIC_LINK_LOGIN == "1" - data["is_email_password_enabled"] = ENABLE_EMAIL_PASSWORD == "1" + data["is_magic_login_enabled"] = _is_config_enabled(ENABLE_MAGIC_LINK_LOGIN) + data["is_email_password_enabled"] = _is_config_enabled(ENABLE_EMAIL_PASSWORD)Also applies to: 140-141
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/api/plane/license/api/views/instance.py` around lines 134 - 135, Create/ reuse a boolean-normalization helper (e.g., normalize_bool(value)) and replace the strict == "1" checks for the flags ENABLE_SIGNUP, DISABLE_WORKSPACE_CREATION, ENABLE_MAGIC_LINK_LOGIN, and ENABLE_EMAIL_PASSWORD so the view uses normalized booleans when populating data["enable_signup"], data["is_workspace_creation_disabled"], data["enable_magic_link_login"], and data["enable_email_password"]; locate these variables in the instance view (functions referencing ENABLE_SIGNUP, DISABLE_WORKSPACE_CREATION, ENABLE_MAGIC_LINK_LOGIN, ENABLE_EMAIL_PASSWORD) and call normalize_bool(...) on each config value before assigning to the data dict.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/api/plane/license/api/views/instance.py`:
- Around line 134-135: Create/ reuse a boolean-normalization helper (e.g.,
normalize_bool(value)) and replace the strict == "1" checks for the flags
ENABLE_SIGNUP, DISABLE_WORKSPACE_CREATION, ENABLE_MAGIC_LINK_LOGIN, and
ENABLE_EMAIL_PASSWORD so the view uses normalized booleans when populating
data["enable_signup"], data["is_workspace_creation_disabled"],
data["enable_magic_link_login"], and data["enable_email_password"]; locate these
variables in the instance view (functions referencing ENABLE_SIGNUP,
DISABLE_WORKSPACE_CREATION, ENABLE_MAGIC_LINK_LOGIN, ENABLE_EMAIL_PASSWORD) and
call normalize_bool(...) on each config value before assigning to the data dict.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b43dca59-07af-40e3-89c4-239ad8514b89
📒 Files selected for processing (1)
apps/api/plane/license/api/views/instance.py
Description
Fixes the issue where OAuth providers such as Gitea were not rendered on the login page when self-hosted instances used boolean-like config values such as
"true"instead of"1".The issue occurred because OAuth provider flags were serialized using strict
"1"comparisons.This change normalizes OAuth provider config checks so values like:
"1""true""TRUE"" true "are treated as enabled.
The fix is scoped only to OAuth provider flags:
Closes #9124
Type of Change
Test Scenarios
"1"resolves to enabled"true"resolves to enabled"0"and"false"remain disabledReferences
Issue: #9124
Summary by CodeRabbit