{"record":{"id":"cb740d517d241009","repo":"phacility/phabricator","slug":"specify-one-or-more-queries-to-export-with-quer","errorCode":null,"errorMessage":"Specify one or more queries to export with \"--query\".","messagePattern":"Specify one or more queries to export with \"--query\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php","lineNumber":157,"sourceCode":"        \"%s\\n\",\n        pht(\n          'Exported data to \"%s\".',\n          Filesystem::readablePath($output_path)));\n    } else {\n      foreach ($iterator as $chunk) {\n        echo $chunk;\n      }\n    }\n\n    return 0;\n  }\n\n  private function newQueries(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $query_keys = $args->getArg('query');\n    if (!$query_keys) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify one or more queries to export with \"--query\".'));\n    }\n\n    $engine_classes = id(new PhutilClassMapQuery())\n      ->setAncestorClass('PhabricatorApplicationSearchEngine')\n      ->execute();\n\n    $class = $args->getArg('class');\n    if (strlen($class)) {\n\n      $class_list = array();\n      foreach ($engine_classes as $class_name => $engine_object) {\n        $can_export = id(clone $engine_object)\n          ->setViewer($viewer)\n          ->canExport();\n        if ($can_export) {\n          $class_list[] = $class_name;","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php#L139-L175","documentation":"The export workflow needs at least one query selected with --query. With no query keys at all ($args->getArg('query') empty), it throws this usage exception immediately. Query keys are either builtin names (like 'all') or the saved-query keys visible in the web UI search URL (queryKey parameter).","triggerScenarios":"Calling `bin/bulk export` with --format/--output but no --query argument; passing --query via a wrapper script where the variable expanded to an empty value.","commonSituations":"Converting a UI search into a CLI export and forgetting the query key; scripts where an unquoted or unset $QUERY variable expanded to nothing; copying a command template but deleting the query part.","solutions":["Pass a saved query key: run the search in the web UI and copy the queryKey from the URL.","Pass a builtin query name such as --query all together with --class <EngineClassName>.","Assert the variable is nonempty in scripts before invoking: test -n \"$QUERY\" || exit 2."],"exampleFix":"# before\nbin/bulk export --format csv --output -\n# after\nbin/bulk export --format csv --output - --class ManiphestTaskSearchEngine --query all","handlingStrategy":"validation","validationCode":"test -n \"$QUERY\" || { echo 'QUERY is empty; refusing to export' >&2; exit 2; }\nbin/bulk export --query \"$QUERY\" --output -","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use set -u in bash so unset variables abort the script.","Copy query keys from the web UI URL rather than typing them.","Pair every builtin query name with an explicit --class."],"tags":["phabricator","cli","export","query"],"backgroundTag":"cli-argument-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}