{"record":{"id":"949fec3a07644fe2","repo":"phacility/phabricator","slug":"choose-a-build-target-to-attach-the-log-to-with","errorCode":null,"errorMessage":"Choose a build target to attach the log to with \"--target\".","messagePattern":"Choose a build target to attach the log to with \"--target\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php","lineNumber":36,"sourceCode":"            'param' => 'id',\n            'help' => pht('Build Target ID to attach the log to.'),\n          ),\n          array(\n            'name' => 'rate',\n            'param' => 'bytes',\n            'help' => pht(\n              'Limit the rate at which the log is written, to test '.\n              'live log streaming.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $target_id = $args->getArg('target');\n    if (!$target_id) {\n      throw new PhutilArgumentUsageException(\n        pht('Choose a build target to attach the log to with \"--target\".'));\n    }\n\n    $target = id(new HarbormasterBuildTargetQuery())\n      ->setViewer($viewer)\n      ->withIDs(array($target_id))\n      ->executeOne();\n    if (!$target) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to load build target \"%s\".',\n          $target_id));\n    }\n\n    $log = HarbormasterBuildLog::initializeNewBuildLog($target);\n    $log->openBuildLog();\n\n    echo tsprintf(","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php#L18-L54","documentation":"Usage exception from 'bin/harbormaster write-log', a debugging tool that reads stdin and writes it into a new live build log. A HarbormasterBuildLog must belong to a HarbormasterBuildTarget, and --target is the only way to name one, so a missing --target aborts before any log is created.","triggerScenarios":"Running 'echo hi | bin/harbormaster write-log' with no --target flag.","commonSituations":"Testing live log streaming and forgetting the target; a script variable holding the target ID is empty.","solutions":["Get a target ID from the build page (the target URI contains the numeric ID) and pass '--target <id>'","Run a build first so a real target exists to attach the test log to"],"exampleFix":"# before\n$ echo hi | bin/harbormaster write-log\n# after\n$ echo hi | bin/harbormaster write-log --target 33","handlingStrategy":"validation","validationCode":"# shell wrapper before invoking write-log\nif [ -z ${TARGET_ID:-} ]; then\n  echo 'error: --target <id> is required' >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a build first and copy a real target ID before testing write-log","Check that the target ID variable is non-empty in scripts"],"tags":["harbormaster","phabricator","cli","missing-option","build-log"],"backgroundTag":"missing-required-option","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}