{"record":{"id":"563a8de9898c129b","repo":"phacility/phabricator","slug":"configuration-file-s-exists-and-is-readable-bu","errorCode":null,"errorMessage":"Configuration file \"%s\" exists and is readable, but the content is not valid JSON. You may have edited this file manually and introduced a syntax error by mistake. Correct the file syntax to continue.","messagePattern":"Configuration file \"(.+?)\" exists and is readable, but the content is not valid JSON\\. You may have edited this file manually and introduced a syntax error by mistake\\. Correct the file syntax to continue\\.","errorType":"exception","errorClass":"PhutilProxyException","httpStatus":null,"severity":"critical","filePath":"src/infrastructure/env/PhabricatorConfigLocalSource.php","lineNumber":42,"sourceCode":"\n    if (!Filesystem::pathExists($path)) {\n      return array();\n    }\n\n    try {\n      $data = Filesystem::readFile($path);\n    } catch (FilesystemException $ex) {\n      throw new PhutilProxyException(\n        pht(\n          'Configuration file \"%s\" exists, but could not be read.',\n          $path),\n        $ex);\n    }\n\n    try {\n      $result = phutil_json_decode($data);\n    } catch (PhutilJSONParserException $ex) {\n      throw new PhutilProxyException(\n        pht(\n          'Configuration file \"%s\" exists and is readable, but the content '.\n          'is not valid JSON. You may have edited this file manually and '.\n          'introduced a syntax error by mistake. Correct the file syntax '.\n          'to continue.',\n          $path),\n        $ex);\n    }\n\n    return $result;\n  }\n\n  private function saveConfig() {\n    $config = $this->getSource()->getAllKeys();\n    $json = new PhutilJSON();\n    $data = $json->encodeFormatted($config);\n    Filesystem::writeFile($this->getConfigPath(), $data);\n  }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/env/PhabricatorConfigLocalSource.php#L24-L60","documentation":"After successfully reading conf/local/local.json, PhabricatorConfigLocalSource decodes it with phutil_json_decode(); if the content is not valid JSON (trailing comma, smart quotes, comment lines, truncation), the PhutilJSONParserException is proxied with this message. Phabricator refuses to guess a partial config, so the invalid file halts config loading instance-wide.","triggerScenarios":"Hand-editing conf/local/local.json and saving a syntax error - unquoted keys, a trailing comma after the last entry, single quotes, a stray semicolon, or a file truncated by an interrupted editor session; then any request or bin script that boots the env.","commonSituations":"Operators hand-editing local.json under time pressure instead of using ./bin/config set; merge conflict artifacts left in the file; editors inserting BOM or pretty-printing with wrong quoting; copying config snippets from wiki pages that include comments.","solutions":["Validate and fix the file: php -r 'json_decode(file_get_contents(\"conf/local/local.json\")); echo json_last_error_msg();' then correct the reported position (usually trailing comma or unquoted key).","Prefer writing values through `./bin/config set <key> <json>` which serializes valid JSON for you.","Keep local.json in version control or backups so a broken edit can be reverted instantly."],"exampleFix":"// before: conf/local/local.json with trailing comma\n{\n  \"phabricator.base-uri\": \"https://phab.example.com\",\n}\n\n// after: strict JSON\n{\n  \"phabricator.base-uri\": \"https://phab.example.com\"\n}","handlingStrategy":"validation","validationCode":"$path = PhabricatorEnv::getEnvConfig(...) ? null : 'conf/local/local.json';\n$json = file_get_contents('conf/local/local.json');\nif (json_decode($json) === null && json_last_error() !== JSON_ERROR_NONE) {\n  throw new Exception('local.json: '.json_last_error_msg());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write config only via ./bin/config set; never hand-edit local.json.","Keep local.json in git or a backup so broken edits are one revert away.","Add a CI/pre-deploy check: php -r 'json_decode(file_get_contents(\"conf/local/local.json\")); exit(json_last_error()===JSON_ERROR_NONE?0:1);'."],"tags":["phabricator","config","json","local-json","parse-error","boot"],"backgroundTag":"config-file-json-invalid","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}