From cd494458a75c2c74759abe8426029d73f3677c51 Mon Sep 17 00:00:00 2001 From: sangeethailango Date: Wed, 24 Jun 2026 12:10:16 +0530 Subject: [PATCH 1/2] fix: create InstanceConfiguration for all 4 keys --- .../license/management/commands/configure_instance.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/api/plane/license/management/commands/configure_instance.py b/apps/api/plane/license/management/commands/configure_instance.py index 43026a45543..7fd6ef61078 100644 --- a/apps/api/plane/license/management/commands/configure_instance.py +++ b/apps/api/plane/license/management/commands/configure_instance.py @@ -41,8 +41,12 @@ def handle(self, *args, **options): self.stdout.write(self.style.WARNING(f"{obj.key} configuration already exists")) keys = ["IS_GOOGLE_ENABLED", "IS_GITHUB_ENABLED", "IS_GITLAB_ENABLED", "IS_GITEA_ENABLED"] - if not InstanceConfiguration.objects.filter(key__in=keys).exists(): - for key in keys: + + existed_keys = InstanceConfiguration.objects.filter(key__in=keys).values_list("key", flat=True) + missing_keys = set(keys) - set(existed_keys) + + if missing_keys: + for key in missing_keys: if key == "IS_GOOGLE_ENABLED": GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET = get_configuration_value( [ From e6152e3e084db3bb622dcf2db5aca8f1a97a5305 Mon Sep 17 00:00:00 2001 From: sangeethailango Date: Mon, 29 Jun 2026 18:59:08 +0530 Subject: [PATCH 2/2] fix: added missing keys in core.py --- .../management/commands/configure_instance.py | 116 ------------------ .../utils/instance_config_variables/core.py | 18 +++ 2 files changed, 18 insertions(+), 116 deletions(-) diff --git a/apps/api/plane/license/management/commands/configure_instance.py b/apps/api/plane/license/management/commands/configure_instance.py index 7fd6ef61078..7b2007efa37 100644 --- a/apps/api/plane/license/management/commands/configure_instance.py +++ b/apps/api/plane/license/management/commands/configure_instance.py @@ -18,7 +18,6 @@ class Command(BaseCommand): def handle(self, *args, **options): from plane.license.utils.encryption import encrypt_data - from plane.license.utils.instance_value import get_configuration_value mandatory_keys = ["SECRET_KEY"] @@ -39,118 +38,3 @@ def handle(self, *args, **options): self.stdout.write(self.style.SUCCESS(f"{obj.key} loaded with value from environment variable.")) else: self.stdout.write(self.style.WARNING(f"{obj.key} configuration already exists")) - - keys = ["IS_GOOGLE_ENABLED", "IS_GITHUB_ENABLED", "IS_GITLAB_ENABLED", "IS_GITEA_ENABLED"] - - existed_keys = InstanceConfiguration.objects.filter(key__in=keys).values_list("key", flat=True) - missing_keys = set(keys) - set(existed_keys) - - if missing_keys: - for key in missing_keys: - if key == "IS_GOOGLE_ENABLED": - GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET = get_configuration_value( - [ - { - "key": "GOOGLE_CLIENT_ID", - "default": os.environ.get("GOOGLE_CLIENT_ID", ""), - }, - { - "key": "GOOGLE_CLIENT_SECRET", - "default": os.environ.get("GOOGLE_CLIENT_SECRET", "0"), - }, - ] - ) - if bool(GOOGLE_CLIENT_ID) and bool(GOOGLE_CLIENT_SECRET): - value = "1" - else: - value = "0" - InstanceConfiguration.objects.create( - key=key, - value=value, - category="AUTHENTICATION", - is_encrypted=False, - ) - self.stdout.write(self.style.SUCCESS(f"{key} loaded with value from environment variable.")) - if key == "IS_GITHUB_ENABLED": - GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET = get_configuration_value( - [ - { - "key": "GITHUB_CLIENT_ID", - "default": os.environ.get("GITHUB_CLIENT_ID", ""), - }, - { - "key": "GITHUB_CLIENT_SECRET", - "default": os.environ.get("GITHUB_CLIENT_SECRET", "0"), - }, - ] - ) - if bool(GITHUB_CLIENT_ID) and bool(GITHUB_CLIENT_SECRET): - value = "1" - else: - value = "0" - InstanceConfiguration.objects.create( - key="IS_GITHUB_ENABLED", - value=value, - category="AUTHENTICATION", - is_encrypted=False, - ) - self.stdout.write(self.style.SUCCESS(f"{key} loaded with value from environment variable.")) - if key == "IS_GITLAB_ENABLED": - GITLAB_HOST, GITLAB_CLIENT_ID, GITLAB_CLIENT_SECRET = get_configuration_value( - [ - { - "key": "GITLAB_HOST", - "default": os.environ.get("GITLAB_HOST", "https://gitlab.com"), - }, - { - "key": "GITLAB_CLIENT_ID", - "default": os.environ.get("GITLAB_CLIENT_ID", ""), - }, - { - "key": "GITLAB_CLIENT_SECRET", - "default": os.environ.get("GITLAB_CLIENT_SECRET", ""), - }, - ] - ) - if bool(GITLAB_HOST) and bool(GITLAB_CLIENT_ID) and bool(GITLAB_CLIENT_SECRET): - value = "1" - else: - value = "0" - InstanceConfiguration.objects.create( - key="IS_GITLAB_ENABLED", - value=value, - category="AUTHENTICATION", - is_encrypted=False, - ) - self.stdout.write(self.style.SUCCESS(f"{key} loaded with value from environment variable.")) - if key == "IS_GITEA_ENABLED": - GITEA_HOST, GITEA_CLIENT_ID, GITEA_CLIENT_SECRET = get_configuration_value( - [ - { - "key": "GITEA_HOST", - "default": os.environ.get("GITEA_HOST", ""), - }, - { - "key": "GITEA_CLIENT_ID", - "default": os.environ.get("GITEA_CLIENT_ID", ""), - }, - { - "key": "GITEA_CLIENT_SECRET", - "default": os.environ.get("GITEA_CLIENT_SECRET", ""), - }, - ] - ) - if bool(GITEA_HOST) and bool(GITEA_CLIENT_ID) and bool(GITEA_CLIENT_SECRET): - value = "1" - else: - value = "0" - InstanceConfiguration.objects.create( - key="IS_GITEA_ENABLED", - value=value, - category="AUTHENTICATION", - is_encrypted=False, - ) - self.stdout.write(self.style.SUCCESS(f"{key} loaded with value from environment variable.")) - else: - for key in keys: - self.stdout.write(self.style.WARNING(f"{key} configuration already exists")) diff --git a/apps/api/plane/utils/instance_config_variables/core.py b/apps/api/plane/utils/instance_config_variables/core.py index 6eebf0b3adb..6df27d26170 100644 --- a/apps/api/plane/utils/instance_config_variables/core.py +++ b/apps/api/plane/utils/instance_config_variables/core.py @@ -36,6 +36,12 @@ ] google_config_variables = [ + { + "key": "IS_GOOGLE_ENABLED", + "value": os.environ.get("IS_GOOGLE_ENABLED", "0"), + "category": "GOOGLE", + "is_encrypted": False, + }, { "key": "GOOGLE_CLIENT_ID", "value": os.environ.get("GOOGLE_CLIENT_ID"), @@ -57,6 +63,12 @@ ] github_config_variables = [ + { + "key": "IS_GITHUB_ENABLED", + "value": os.environ.get("IS_GITHUB_ENABLED", "0"), + "category": "GITHUB", + "is_encrypted": False, + }, { "key": "GITHUB_CLIENT_ID", "value": os.environ.get("GITHUB_CLIENT_ID"), @@ -85,6 +97,12 @@ gitlab_config_variables = [ + { + "key": "IS_GITLAB_ENABLED", + "value": os.environ.get("IS_GITLAB_ENABLED", "0"), + "category": "GITLAB", + "is_encrypted": False, + }, { "key": "GITLAB_HOST", "value": os.environ.get("GITLAB_HOST"),