{"record":{"id":"79b287fd1f820b84","repo":"makeplane/plane","slug":"item-env-variable-is-required","errorCode":null,"errorMessage":"{item} env variable is required.","messagePattern":"(.+?) env variable is required\\.","errorType":"console","errorClass":"CommandError","httpStatus":null,"severity":"critical","filePath":"apps/api/plane/license/management/commands/configure_instance.py","lineNumber":26,"sourceCode":"# Django imports\nfrom django.core.management.base import BaseCommand, CommandError\n\n# Module imports\nfrom plane.license.models import InstanceConfiguration\nfrom plane.utils.instance_config_variables import instance_config_variables\n\n\nclass Command(BaseCommand):\n    help = \"Configure instance variables\"\n\n    def handle(self, *args, **options):\n        from plane.license.utils.encryption import encrypt_data\n\n        mandatory_keys = [\"SECRET_KEY\"]\n\n        for item in mandatory_keys:\n            if not os.environ.get(item):\n                raise CommandError(f\"{item} env variable is required.\")\n\n        for item in instance_config_variables:\n            obj, created = InstanceConfiguration.objects.get_or_create(key=item.get(\"key\"))\n            if created:\n                obj.category = item.get(\"category\")\n                obj.is_encrypted = item.get(\"is_encrypted\", False)\n                if item.get(\"is_encrypted\", False):\n                    obj.value = encrypt_data(item.get(\"value\"))\n                else:\n                    obj.value = item.get(\"value\")\n                obj.save()\n                self.stdout.write(self.style.SUCCESS(f\"{obj.key} loaded with value from environment variable.\"))\n            else:\n                self.stdout.write(self.style.WARNING(f\"{obj.key} configuration already exists\"))\n","sourceCodeStart":8,"sourceCodeEnd":41,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/license/management/commands/configure_instance.py#L8-L41","documentation":"CommandError raised by the `configure_instance` management command when the `SECRET_KEY` environment variable is unset/empty. `mandatory_keys = [\"SECRET_KEY\"]` and the loop checks `os.environ.get(item)` for a truthy value before seeding InstanceConfiguration rows. SECRET_KEY is the only hard-blocked key; all other instance config vars fall back to defaults.","triggerScenarios":"Running `python manage.py configure_instance` without `SECRET_KEY` exported in the environment. The command aborts before writing any InstanceConfiguration rows.","commonSituations":"Fresh self-hosted install where `.env` was copied from `.env.example` but SECRET_KEY left blank; running the command in a shell/CI job that did not source the env file; Docker container started without the SECRET_KEY env var passed through.","solutions":["Generate and export a SECRET_KEY before running the command: `export SECRET_KEY=$(python -c \"import secrets; print(secrets.token_urlsafe(50))\")`.","Ensure your `.env` (or docker-compose env_file) has a non-empty SECRET_KEY and that the process actually sources it.","Re-run `python manage.py configure_instance` once SECRET_KEY is set.","Verify with `echo ${SECRET_KEY:?unset}` that the var is non-empty in the exact shell running the command."],"exampleFix":"# before - .env\nSECRET_KEY=\n\n# after\nSECRET_KEY=replace-with-50+-char-random-string","handlingStrategy":"validation","validationCode":"import os\n\ndef has_mandatory_env() -> bool:\n    # mirrors configure_instance.py:25 mandatory_keys\n    return all(os.environ.get(k) for k in ['SECRET_KEY'])","typeGuard":null,"tryCatchPattern":"from django.core.management.base import CommandError\ntry:\n    call_command('configure_instance')\nexcept CommandError as e:\n    if 'SECRET_KEY' in str(e):\n        generate_and_export_secret_key()","preventionTips":["Set a strong SECRET_KEY in .env before any setup command.","Verify with `echo ${SECRET_KEY:?unset}` in the running shell.","For Docker, pass SECRET_KEY through the compose env_file."],"tags":["environment","management-command","setup","secret-key"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}