phacility/phabricator · error · PhutilArgumentUsageException
Failed to read stdin.
Error message
Failed to read stdin.
What it means
Thrown by the `bin/repository hint` workflow in Phabricator/Phorge when `file_get_contents('php://stdin')` returns false, meaning the PHP process could not read anything from standard input. This workflow expects a JSON document describing commit hints to be piped into it rather than passed as arguments. The error is a usage guard so the command fails fast before attempting any JSON parsing or database writes.
Source
Thrown at src/applications/repository/management/PhabricatorRepositoryManagementHintWorkflow.php:25
$this
->setName('hint')
->setExamples('**hint** [options] ...')
->setSynopsis(
pht(
'Write hints about unusual (rewritten or unreadable) commits.'))
->setArguments(array());
}
public function execute(PhutilArgumentParser $args) {
$viewer = $this->getViewer();
echo tsprintf(
"%s\n",
pht('Reading list of hints from stdin...'));
$hints = file_get_contents('php://stdin');
if ($hints === false) {
throw new PhutilArgumentUsageException(pht('Failed to read stdin.'));
}
try {
$hints = phutil_json_decode($hints);
} catch (Exception $ex) {
throw new PhutilArgumentUsageException(
pht(
'Expected a list of hints in JSON format: %s',
$ex->getMessage()));
}
$repositories = array();
foreach ($hints as $idx => $hint) {
if (!is_array($hint)) {
throw new PhutilArgumentUsageException(
pht(
'Each item in the list of hints should be a JSON object, but '.
'the item at index "%s" is not.',View on GitHub (pinned to 5720a38cfe)
Solutions
- Pipe the JSON payload in: `./bin/repository hint < hints.json` or `cat hints.json | ./bin/repository hint`.
- If redirecting from a file, verify it exists and is readable by the user running the command (`ls -l hints.json`).
- In cron/sudo contexts, redirect stdin explicitly from a real file rather than leaving it detached.
- Verify PHP can open the stream: `php -r 'var_dump(file_get_contents("php://stdin"));' < hints.json`.
Example fix
// before $ ./bin/repository hint # no stdin attached [1160] Failed to read stdin. // after $ ./bin/repository hint < /path/to/hints.json
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/bash
HINTS=/path/to/hints.json
[ -r "$HINTS" ] || { echo "hints file missing/unreadable" >&2; exit 1; }
./bin/repository hint < "$HINTS" Prevention
- Always invoke the hint workflow with an explicit file redirection rather than relying on inherited stdin.
- Test the pipeline with `echo '[]' | ./bin/repository hint` (valid empty list) before feeding real data.
- In cron/systemd units, set StandardInput=file or redirect from a file so the stream is always readable.
When it happens
Trigger: Running `./bin/repository hint` with no pipe or input redirection (empty stdin in a non-interactive shell); redirecting stdin from an unreadable or permission-denied file (`./bin/repository hint < /root/secret-hints.json` as a user without read access); running under cron/sudo where stdin is closed; a broken pipe (`echo ... | ./bin/repository hint` where the echo side fails).
Common situations: Operators migrating rewritten history (e.g. after `git filter-repo`) forget the workflow takes input on stdin, not as CLI args. CI jobs or cron scripts invoke the command with stdin detached (e.g. `< /dev/null` on a platform where the read errors, or under `nohup` without redirection).
Related errors
- Expected a list of hints in JSON format: %s
- Each item in the list of hints should be a JSON object, but
- Request parameter "%s" is not formatted properly. Expected a
- Request parameter "%s" is not formatted properly. Expected a
- Invalid Request (CSRF)
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/03cde741d6688204.
Report an issue: GitHub.