{"record":{"id":"03cde741d6688204","repo":"phacility/phabricator","slug":"failed-to-read-stdin","errorCode":null,"errorMessage":"Failed to read stdin.","messagePattern":"Failed to read stdin\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/repository/management/PhabricatorRepositoryManagementHintWorkflow.php","lineNumber":25,"sourceCode":"    $this\n      ->setName('hint')\n      ->setExamples('**hint** [options] ...')\n      ->setSynopsis(\n        pht(\n          'Write hints about unusual (rewritten or unreadable) commits.'))\n      ->setArguments(array());\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    echo tsprintf(\n      \"%s\\n\",\n      pht('Reading list of hints from stdin...'));\n\n    $hints = file_get_contents('php://stdin');\n    if ($hints === false) {\n      throw new PhutilArgumentUsageException(pht('Failed to read stdin.'));\n    }\n\n    try {\n      $hints = phutil_json_decode($hints);\n    } catch (Exception $ex) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Expected a list of hints in JSON format: %s',\n          $ex->getMessage()));\n    }\n\n    $repositories = array();\n    foreach ($hints as $idx => $hint) {\n      if (!is_array($hint)) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Each item in the list of hints should be a JSON object, but '.\n            'the item at index \"%s\" is not.',","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/repository/management/PhabricatorRepositoryManagementHintWorkflow.php#L7-L43","documentation":"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.","triggerScenarios":"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).","commonSituations":"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).","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`."],"exampleFix":"// before\n$ ./bin/repository hint   # no stdin attached\n[1160] Failed to read stdin.\n\n// after\n$ ./bin/repository hint < /path/to/hints.json","handlingStrategy":"validation","validationCode":"#!/bin/bash\nHINTS=/path/to/hints.json\n[ -r \"$HINTS\" ] || { echo \"hints file missing/unreadable\" >&2; exit 1; }\n./bin/repository hint < \"$HINTS\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["phabricator","phorge","cli","stdin","repository-management"],"backgroundTag":"stdin-read-failure","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}