{"record":{"id":"8facd7503115e561","repo":"phacility/phabricator","slug":"configuration-file-is-not-properly-formatted-json","errorCode":null,"errorMessage":"Configuration file is not properly formatted JSON. %s","messagePattern":"Configuration file is not properly formatted JSON\\. (.+?)","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php","lineNumber":67,"sourceCode":"    echo tsprintf(\n      \"%s\\n\",\n      pht(\n        'Reading configuration from: %s',\n        $show_path));\n\n    try {\n      $data = Filesystem::readFile($full_path);\n    } catch (Exception $ex) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Failed to read configuration file. %s',\n          $ex->getMessage()));\n    }\n\n    try {\n      $data = phutil_json_decode($data);\n    } catch (Exception $ex) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Configuration file is not properly formatted JSON. %s',\n          $ex->getMessage()));\n    }\n\n    try {\n      PhutilTypeSpec::checkMap(\n        $data,\n        array(\n          'servers' => 'list<wild>',\n          'logs' => 'optional list<wild>',\n          'cluster' => 'optional list<wild>',\n          'pidfile' => 'string',\n          'memory.hint' => 'optional int',\n        ));\n    } catch (Exception $ex) {\n      throw new PhutilArgumentUsageException(\n        pht(","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php#L49-L85","documentation":"Thrown by the Aphlict (Phabricator notification server) management workflow when the file given via --config cannot be decoded as JSON. The raw file contents are passed to phutil_json_decode(), and any decode failure is wrapped in this PhutilArgumentUsageException. It signals that the user-supplied config file is syntactically invalid, before any schema or semantic validation happens.","triggerScenarios":"Running any bin/aphlict subcommand (start, stop, restart, debug, config) with --config pointing at a file that json_decode rejects: trailing commas, single quotes around strings, // or /* */ comments, unquoted keys, a UTF-8 BOM, or a truncated file.","commonSituations":"Admins copy a JSON example from a wiki/blog that contains comments, or edit the config in an editor that saves a BOM; CI pipelines generate a truncated file; someone converts an old .conf-style file to JSON and leaves legacy syntax.","solutions":["Validate syntax before starting: php -r 'json_decode(file_get_contents(\"conf/aphlict.json\")); echo json_last_error_msg();' or `jq . conf/aphlict.json`","Remove comments, trailing commas, and single-quoted strings; make every key a double-quoted JSON string","Re-save the file as plain UTF-8 without BOM and confirm it is complete (matching braces)","Run `bin/aphlict config --test conf/aphlict.json` (if available in your version) to iterate on config errors safely"],"exampleFix":"// conf/aphlict.json — before (invalid: comment + trailing comma)\n{\n  // notification server\n  \"servers\": [{\"type\": \"client\", \"port\": 22280,},],\n}\n// after\n{\n  \"servers\": [{\"type\": \"client\", \"port\": 22280}],\n}","handlingStrategy":"validation","validationCode":"$raw = Filesystem::readFile($config_path);\nif (json_decode($raw) === null && json_last_error() !== JSON_ERROR_NONE) {\n  throw new InvalidArgumentException(\n    'Aphlict config is not valid JSON: '.json_last_error_msg());\n}\n// or from the shell: jq . conf/aphlict.json > /dev/null","typeGuard":null,"tryCatchPattern":"try {\n  (new PhabricatorAphlictStartWorkflow())->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Config/usage error from the admin; print and exit non-zero.\n  fwrite(STDERR, $ex->getMessage().\"\\n\");\n  exit(1);\n}","preventionTips":["Lint the config with jq or php json_decode in CI before deploying","Keep configs comment-free; put explanatory notes in a separate README, not the JSON","Save aphlict config as UTF-8 without BOM and let the editor re-validate on save"],"tags":["aphlict","json","configuration","cli","phabricator"],"backgroundTag":"invalid-json-config","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}