{"record":{"id":"d0c12787d5dc914e","repo":"makeplane/plane","slug":"machine-signature-is-required","errorCode":null,"errorMessage":"Machine signature is required","messagePattern":"Machine signature is required","errorType":"console","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/license/management/commands/register_instance.py","lineNumber":65,"sourceCode":"            data = response.json()\n            return data.get(\"tag_name\", fallback_version)\n        except Exception:\n            self.stdout.write(\"Error checking for latest version\")\n            return fallback_version\n\n    def handle(self, *args, **options):\n        # Check if the instance is registered\n        instance = Instance.objects.first()\n\n        current_version = self.check_for_current_version()\n        latest_version = self.check_for_latest_version(current_version)\n\n        # If instance is None then register this instance\n        if instance is None:\n            machine_signature = options.get(\"machine_signature\", \"machine-signature\")\n\n            if not machine_signature:\n                raise CommandError(\"Machine signature is required\")\n\n            instance = Instance.objects.create(\n                instance_name=\"Plane Community Edition\",\n                instance_id=secrets.token_hex(12),\n                current_version=current_version,\n                latest_version=latest_version,\n                last_checked_at=timezone.now(),\n                is_test=os.environ.get(\"IS_TEST\", \"0\") == \"1\",\n                edition=InstanceEdition.PLANE_COMMUNITY.value,\n            )\n\n            self.stdout.write(self.style.SUCCESS(\"Instance registered\"))\n        else:\n            self.stdout.write(self.style.SUCCESS(\"Instance already registered\"))\n\n            # Update the instance details\n            instance.last_checked_at = timezone.now()\n            instance.current_version = current_version","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/license/management/commands/register_instance.py#L47-L83","documentation":"CommandError raised by `register_instance` when the `machine_signature` argument is falsy. Note a latent bug: `options.get(\"machine_signature\", \"machine-signature\")` supplies a truthy default, so the `if not machine_signature` branch can only fire when an empty string is explicitly passed - argparse already makes the positional required, so this guard is largely defensive. The raised error blocks Instance creation.","triggerScenarios":"Running `python manage.py register_instance \"\"` (explicit empty string). A bare `python manage.py register_instance` fails earlier at argparse because machine_signature is a required positional argument; passing a real signature string registers the instance successfully.","commonSituations":"Automation/wrapper scripts that pass an empty machine_signature under some code path; misconfigured installers that derive the signature from an unset env var and pass `\"\"`; calling the command programmatically with a populated options dict that has `machine_signature: None`.","solutions":["Pass a non-empty machine_signature positional: `python manage.py register_instance <unique-host-id>`.","In wrapper scripts, default to a stable unique value (hostname, MAC hash, or a generated UUID) rather than an empty string.","If invoking programmatically, ensure `options[\"machine_signature\"]` is a non-empty string before calling `handle()`.","Consider fixing the misleading `options.get(..., \"machine-signature\")` default so the guard is meaningful, or remove it since argparse enforces presence."],"exampleFix":"# before\npython manage.py register_instance \"\"\n\n# after\npython manage.py register_instance \"$(hostname)-$(sha256sum /etc/machine-id | cut -c1-16)\"","handlingStrategy":"validation","validationCode":"def is_valid_signature(sig) -> bool:\n    # register_instance requires a non-empty positional signature\n    return isinstance(sig, str) and bool(sig.strip())\n\n# wrapper scripts should default to a stable unique value, never ''","typeGuard":null,"tryCatchPattern":"from django.core.management.base import CommandError\ntry:\n    call_command('register_instance', signature)\nexcept CommandError as e:\n    if 'Machine signature' in str(e):\n        signature = derive_machine_id(); call_command('register_instance', signature)","preventionTips":["Always pass a non-empty positional machine_signature.","Derive a stable signature from hostname/machine-id in wrapper scripts.","Do not rely on the options.get default; pass the value explicitly."],"tags":["management-command","setup","instance-registration"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}