HKUDS/nanobot · error · ConfigLoadError

The top level of config.json must be a JSON object.

Error message

The top level of config.json must be a JSON object.

What it means

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.

Solutions

  1. Wrap settings in a top-level object, e.g. {"agents": {}, "providers": {}}
  2. Remove accidental array/string wrappers around the config
  3. Start from a fresh default config and re-apply settings
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/config/loader.py:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/36b9619d9afa936c. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/config/loader.py:110

            ),
        ) from exc
    except UnicodeDecodeError as exc:
        raise ConfigLoadError(
            path,
            kind="io_error",
            summary="The file is not valid UTF-8.",
        ) from exc
    except OSError as exc:
        detail = exc.strerror or type(exc).__name__
        raise ConfigLoadError(
            path,
            kind="io_error",
            summary=f"Unable to read the file: {_sentence(detail)}",
        ) from exc

    if not isinstance(data, dict):
        root_type = type(data).__name__
        raise ConfigLoadError(
            path,
            kind="invalid_root",
            summary="The top level of config.json must be a JSON object.",
            issues=(
                ConfigIssue(
                    path=(),
                    message=f"Expected an object, but found {root_type}.",
                ),
            ),
        )

    data = _migrate_config(cast(dict[str, Any], data))
    try:
        config = Config.model_validate(data)
    except ValidationError as exc:
        issues = validation_issues(exc)
        raise ConfigLoadError(
            path,

View on GitHub (pinned to 42f37dc4c0)