{"record":{"id":"e20e4a8db4a3af6f","repo":"phacility/phabricator","slug":"specify-a-device-with-device","errorCode":null,"errorMessage":"Specify a device with --device.","messagePattern":"Specify a device with --device\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php","lineNumber":42,"sourceCode":"            'param' => 'name',\n            'help' => pht(\n              'Specify an alternate host identity. This is an advanced '.\n              'feature which allows a pool of devices to share credentials.'),\n          ),\n          array(\n            'name' => 'force',\n            'help' => pht(\n              'Register this host even if keys already exist on disk.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $device_name = $args->getArg('device');\n    if (!strlen($device_name)) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a device with --device.'));\n    }\n\n    $device = id(new AlmanacDeviceQuery())\n      ->setViewer($viewer)\n      ->withNames(array($device_name))\n      ->executeOne();\n    if (!$device) {\n      throw new PhutilArgumentUsageException(\n        pht('No such device \"%s\" exists!', $device_name));\n    }\n\n    $identify_as = $args->getArg('identify-as');\n\n    $raw_device = $device_name;\n    if (strlen($identify_as)) {\n      $raw_device = $identify_as;\n    }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php#L24-L60","documentation":"Usage exception from `bin/almanac register` (AlmanacManagementRegisterWorkflow): the --device flag was omitted or given an empty value. The register workflow installs a device identity (SSH keys) on a host and must know which Almanac device it is acting as, so the argument is mandatory before anything else runs.","triggerScenarios":"Running `bin/almanac register` with no flags; running `bin/almanac register --device \"\"` via a provisioning script where the device name variable is empty; typos like --devices=web1.","commonSituations":"Automated host provisioning where the device name comes from an unset environment variable or template placeholder; running the command from memory without checking `bin/almanac register --help`.","solutions":["Pass the device name: bin/almanac register --device <device-name> --private-key <path>.","In scripts, fail early if the device variable is empty rather than invoking the CLI with a blank flag.","Confirm the exact device name with `bin/almanac device --name ...` or in the Almanac web UI; device names are case-sensitive namespace-normalized names."],"exampleFix":"# before\n$ bin/almanac register --private-key /root/id_device\n\n# after\n$ bin/almanac register --device web-001 --private-key /root/id_device","handlingStrategy":"validation","validationCode":"# shell provisioning guard\n: \"${ALMANAC_DEVICE:?ALMANAC_DEVICE must be set to the device name}\"\nbin/almanac register --device \"$ALMANAC_DEVICE\" --private-key \"$KEY_PATH\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make provisioning scripts fail fast on empty variables (: ${VAR:?}).","Wrap register in a small script that checks required flags once.","Keep a reviewed example invocation in the runbook next to the device inventory."],"tags":["phabricator","almanac","cli","usage-error","register"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}