{"record":{"id":"36b9619d9afa936c","repo":"HKUDS/nanobot","slug":"the-top-level-of-config-json-must-be-a-json-object","errorCode":null,"errorMessage":"The top level of config.json must be a JSON object.","messagePattern":"The top level of config\\.json must be a JSON object\\.","errorType":"exception","errorClass":"ConfigLoadError","httpStatus":null,"severity":"error","filePath":"nanobot/config/loader.py","lineNumber":110,"sourceCode":"            ),\n        ) from exc\n    except UnicodeDecodeError as exc:\n        raise ConfigLoadError(\n            path,\n            kind=\"io_error\",\n            summary=\"The file is not valid UTF-8.\",\n        ) from exc\n    except OSError as exc:\n        detail = exc.strerror or type(exc).__name__\n        raise ConfigLoadError(\n            path,\n            kind=\"io_error\",\n            summary=f\"Unable to read the file: {_sentence(detail)}\",\n        ) from exc\n\n    if not isinstance(data, dict):\n        root_type = type(data).__name__\n        raise ConfigLoadError(\n            path,\n            kind=\"invalid_root\",\n            summary=\"The top level of config.json must be a JSON object.\",\n            issues=(\n                ConfigIssue(\n                    path=(),\n                    message=f\"Expected an object, but found {root_type}.\",\n                ),\n            ),\n        )\n\n    data = _migrate_config(cast(dict[str, Any], data))\n    try:\n        config = Config.model_validate(data)\n    except ValidationError as exc:\n        issues = validation_issues(exc)\n        raise ConfigLoadError(\n            path,","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/config/loader.py#L92-L128","documentation":"In load_config, config.json parsed as valid JSON but its top level is not an object (e.g. an array, string, or number). The schema requires a JSON object mapping section names to settings, so an invalid_root ConfigLoadError is raised with an issue noting the actual type found; the input at fault is the file's root value.","triggerScenarios":"Thrown at nanobot/config/loader.py:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap settings in a top-level object, e.g. {\"agents\": {}, \"providers\": {}}","Remove accidental array/string wrappers around the config","Start from a fresh default config and re-apply settings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","contentChangedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}