{"record":{"id":"6b077a3420500a11","repo":"phacility/phabricator","slug":"specify-exactly-one-buildable-object-by-object-na","errorCode":null,"errorMessage":"Specify exactly one buildable object, by object name.","messagePattern":"Specify exactly one buildable object, by object name\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/harbormaster/management/HarbormasterManagementBuildWorkflow.php","lineNumber":36,"sourceCode":"          array(\n            'name' => 'background',\n            'help' => pht(\n              'Submit builds into the build queue normally instead of '.\n              'running them in the foreground.'),\n          ),\n          array(\n            'name'        => 'buildable',\n            'wildcard'    => true,\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $names = $args->getArg('buildable');\n    if (count($names) != 1) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify exactly one buildable object, by object name.'));\n    }\n\n    $name = head($names);\n\n    $buildable = id(new PhabricatorObjectQuery())\n      ->setViewer($viewer)\n      ->withNames($names)\n      ->executeOne();\n    if (!$buildable) {\n      throw new PhutilArgumentUsageException(\n        pht('No such buildable \"%s\"!', $name));\n    }\n\n    if (!($buildable instanceof HarbormasterBuildableInterface)) {\n      throw new PhutilArgumentUsageException(\n        pht('Object \"%s\" is not a buildable!', $name));\n    }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/management/HarbormasterManagementBuildWorkflow.php#L18-L54","documentation":"Usage error from `bin harbormaster build`: the command takes exactly one positional wildcard naming the object to build (a monogram like D123 or a PHID). Zero names or more than one name fails here before anything is queried.","triggerScenarios":"Running `harbormaster build --plan 3` with no object argument; passing two objects ('D1 D2') hoping for a batch; a shell glob expanding to multiple or zero matches.","commonSituations":"Scripting the command and forgetting the wildcard; assuming the tool builds several objects in one invocation.","solutions":["Provide exactly one name: `./bin/phabricator harbormaster build --plan 3 D123`.","For multiple objects, invoke the command once per object in a loop.","Quote arguments so globs do not expand unexpectedly."],"exampleFix":"# before\n./bin/phabricator harbormaster build --plan 3\n\n# after\n./bin/phabricator harbormaster build --plan 3 D123","handlingStrategy":"validation","validationCode":"if (count($names) !== 1 || !reset($names)) {\n  fwrite(STDERR, \"Specify exactly one buildable object, by object name.\\n\");\n  exit(64);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runBuildWorkflow($args);\n} catch (PhutilArgumentUsageException $e) {\n  fwrite(STDERR, $e->getMessage().\"\\n\");\n  exit(64);\n}","preventionTips":["Wrap harbormaster build invocations in a helper that validates argv (exactly one positional, --plan set) before exec.","Loop over objects one at a time in automation instead of passing them all at once."],"tags":["harbormaster","cli","usage-error","build"],"backgroundTag":"cli-argument-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}