{"record":{"id":"0cf4f9d6ccf216d1","repo":"phacility/phabricator","slug":"each-item-in-the-list-of-hints-should-be-a-json-ob","errorCode":null,"errorMessage":"Each item in the list of hints should be a JSON object, but the item at index \"%s\" is not.","messagePattern":"Each item in the list of hints should be a JSON object, but the item at index \"(.+?)\" is not\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/repository/management/PhabricatorRepositoryManagementHintWorkflow.php","lineNumber":40,"sourceCode":"\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.',\n            $idx));\n      }\n\n      try {\n        PhutilTypeSpec::checkMap(\n          $hint,\n          array(\n            'repository' => 'string|int',\n            'old' => 'string',\n            'new' => 'optional string|null',\n            'hint' => 'string',\n          ));\n      } catch (Exception $ex) {\n        throw new PhutilArgumentUsageException(\n          pht(","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/repository/management/PhabricatorRepositoryManagementHintWorkflow.php#L22-L58","documentation":"Thrown by `bin/repository hint` when the stdin payload decodes as valid JSON but is not a list of objects: the `foreach ($hints as $idx => $hint)` loop hits an element where `is_array($hint)` is false. Each hint entry must be a JSON object (map), not a scalar, string, or null.","triggerScenarios":"Piping a JSON object of objects instead of an array of objects (`{\"0\": {...}}` or `{\"r1\": {...}}`); a list containing scalars like `[\"abc\"]` or `[null]`; piping a single flat object `{\"repository\":...}` which iterates its scalar values; JSON produced from an associative PHP array via `json_encode` without `array_values()`.","commonSituations":"Scripts build `$hints[$callsign] = [...]` keyed by callsign and encode it directly, producing an object whose values iterate as scalars/arrays mixed; mixing one shorthand entry (a bare SHA string) into the list.","solutions":["Wrap each entry in braces and the whole payload in square brackets: an array of objects.","If generating from PHP, use `echo json_encode(array_values($hints));` to strip map keys.","Sanity-check shape first: `jq 'type' hints.json` should say `array` and `jq '.[] | type'` should print only `object`.","Remove stray scalars/nulls from the list."],"exampleFix":"// before\n$ echo '{\"repository\":\"R1\",\"old\":\"deadbeef\",\"hint\":\"obsolete\"}' | ./bin/repository hint\n[1162] ... the item at index \"repository\" is not.\n\n// after\n$ echo '[{\"repository\":\"R1\",\"old\":\"deadbeef\",\"hint\":\"obsolete\"}]' | ./bin/repository hint","handlingStrategy":"validation","validationCode":"jq -e 'type == \"array\" and all(.[]; type == \"object\")' hints.json >/dev/null && ./bin/repository hint < hints.json","typeGuard":"function is_hint_list($decoded): bool {\n  if (!is_array($decoded) || array_keys($decoded) !== range(0, count($decoded) - 1)) {\n    return false; // not a sequential list\n  }\n  foreach ($decoded as $hint) {\n    if (!is_array($hint)) {\n      return false;\n    }\n  }\n  return true;\n}","tryCatchPattern":null,"preventionTips":["When building hints in PHP, wrap with array_values() so you emit a list, not a map.","Never mix bare strings (SHAs) into the list — every entry must be an object.","Validate shape with jq before piping."],"tags":["phabricator","phorge","json","cli","repository-management","type-validation"],"backgroundTag":"json-shape-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}