phacility/phabricator · warning · PhutilArgumentUsageException

Specify a query with --query.

Error message

Specify a query with --query.

What it means

`bin/search query` requires a non-empty --query string (checked with strlen). The raw string is placed into a PhabricatorSearchApplicationSearchEngine saved query and executed against the configured search service, so an empty query has no defined behavior and is rejected up front.

Source

Thrown at src/applications/search/management/PhabricatorSearchManagementQueryWorkflow.php:25

    $this
      ->setName('query')
      ->setSynopsis(
        pht('Run a search query. Intended for debugging and development.'))
      ->setArguments(
        array(
          array(
            'name' => 'query',
            'param' => 'query',
            'help' => pht('Raw query to execute.'),
          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();
    $raw_query = $args->getArg('query');
    if (!strlen($raw_query)) {
      throw new PhutilArgumentUsageException(
        pht('Specify a query with --query.'));
    }

    $engine = id(new PhabricatorSearchApplicationSearchEngine())
      ->setViewer($viewer);

    $saved = $engine->newSavedQuery();
    $saved->setParameter('query', $raw_query);

    $query = $engine->buildQueryFromSavedQuery($saved);
    $pager = $engine->newPagerForSavedQuery($saved);

    $results = $engine->executeQuery($query, $pager);
    if ($results) {
      foreach ($results as $result) {
        echo tsprintf(
          "%s\t%s\n",
          $result->getPHID(),

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Pass a raw query string: `bin/search query --query daemon`
  2. In scripts, guard the variable is non-empty before invoking
  3. Use it to debug search quality/bin/search query --query daemon
  4. Run `bin/search help query` for expected parameters

Example fix

# before
bin/search query

# after
bin/search query --query daemon
Defensive patterns

Strategy: validation

Validate before calling

if (!phutil_nonempty_string($rawQuery)) {
  // refuse before invoking: bin/search query requires a non-empty --query
}

Prevention

When it happens

Trigger: `bin/search query` with no --query, or `--query ''` / `--query "$VAR"` where $VAR expanded empty.

Common situations: Probing the CLI; scripts passing an unset variable; quoting that collapses the value to empty.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/fd1a0c643deec5bc. Report an issue: GitHub.