{"record":{"id":"9651a2d00004a26e","repo":"phacility/phabricator","slug":"use-output-path-to-specify-an-output-file-o","errorCode":null,"errorMessage":"Use \"--output <path>\" to specify an output file, or \"--output -\" to print to stdout.","messagePattern":"Use \"--output <path>\" to specify an output file, or \"--output -\" to print to stdout\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php","lineNumber":81,"sourceCode":"      throw new PhutilArgumentUsageException(\n        pht(\n          'Unknown export format (\"%s\"). Known formats are: %s.',\n          $format_key,\n          implode(', ', array_keys($all_formats))));\n    }\n\n    if (!$format->isExportFormatEnabled()) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Export format (\"%s\") is not enabled.',\n          $format_key));\n    }\n\n    $is_overwrite = $args->getArg('overwrite');\n    $output_path = $args->getArg('output');\n\n    if (!strlen($output_path)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Use \"--output <path>\" to specify an output file, or \"--output -\" '.\n          'to print to stdout.'));\n    }\n\n    if ($output_path === '-') {\n      $is_stdout = true;\n    } else {\n      $is_stdout = false;\n    }\n\n    if ($is_stdout && $is_overwrite) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Flag \"--overwrite\" has no effect when outputting to stdout.'));\n    }\n\n    if (!$is_overwrite) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php#L63-L99","documentation":"Phabricator's bulk export workflow (bin/bulk export) refuses to run when no --output destination was supplied. Every export must state where results go: a file path, or the special value '-' to stream to stdout. This is a PhutilArgumentUsageException, so the command prints the message and exits nonzero before executing any query, preventing an expensive export from silently going nowhere.","triggerScenarios":"Invoking `bin/bulk export` with --format and --query but no --output flag. The check is `!strlen($args->getArg('output'))`, so both a completely absent flag and an explicitly empty string trigger it.","commonSituations":"Cron/backup scripts written against an older CLI that defaulted to stdout; copy-pasting an export command from docs that omit --output; interactive use where the user expects a destination prompt.","solutions":["Add --output <path> to write the export to a file (e.g. --output /tmp/tasks.csv).","Add --output - to print the export to stdout, useful for piping into another command.","Run `bin/bulk help export` to confirm the exact argument names before scripting it."],"exampleFix":"# before\nbin/bulk export --format csv --query all\n# after\nbin/bulk export --format csv --query all --output -","handlingStrategy":"validation","validationCode":"# shell wrapper: refuse to run an export with no --output\ncase \" $* \" in\n  *' --output '*) ;;\n  *) echo 'refusing to export: --output is required' >&2; exit 2 ;;\nesac\nbin/bulk export \"$@\"","typeGuard":null,"tryCatchPattern":"PHP harness: catch PhutilArgumentUsageException around the workflow execute() and map it to a distinct exit code (e.g. 64/EX_USAGE) so pipelines can separate bad invocation from runtime failure.","preventionTips":["Always pass --output explicitly, even for stdout ('--output -').","Script wrappers should validate required flags before invoking the CLI.","Treat any nonzero exit from bin/bulk as a failed invocation and surface stderr in CI logs."],"tags":["phabricator","cli","export","bulk-jobs"],"backgroundTag":"cli-argument-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}