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
- Pass a raw query string: `bin/search query --query daemon`
- In scripts, guard the variable is non-empty before invoking
- Use it to debug search quality/bin/search query --query daemon
- 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
- Guard script variables for emptiness before passing them as --query
- Use `bin/search query --query <term>` as a smoke test after backend changes
- Quote the query so shell expansion cannot blank it
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
- Provide a list of objects to index (like "D123"), or a set o
- Specify a commit to extract the diff from.
- Specify an atomizer class with %s.
- Specify a rule to edit with "--rule <id|monogram>".
- Use flags to specify at least one edit to apply to the rule
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/fd1a0c643deec5bc.
Report an issue: GitHub.