BerriAI/litellm · error · UpError
{path} contains invalid JSON (or its root is not an object);
Error message
{path} contains invalid JSON (or its root is not an object); cannot proceed safely. What it means
Guard loading the proxy UI settings JSON for `lite up`: the file exists but fails validation as an object (corrupt or array root); refusing to continue prevents overwriting the user's settings with an empty dict.
Source
Thrown at litellm/proxy/client/cli/commands/up.py:59
existed: bool
content: dict[str, JsonValue] | None
_SETTINGS_ADAPTER: Final = TypeAdapter(dict[str, JsonValue])
_BACKUP_RECORD_ADAPTER: Final = TypeAdapter(BackupRecord)
def load_json_or_empty(path: Path) -> dict[str, JsonValue]:
if not path.exists():
return {}
with open(path, "r") as f:
content: Final = f.read()
if not content.strip():
return {}
try:
return _SETTINGS_ADAPTER.validate_json(content)
except ValidationError:
raise UpError(f"{path} contains invalid JSON (or its root is not an object); cannot proceed safely.")
def merge_claude_settings(
settings: Mapping[str, JsonValue], base_url: str, api_key_helper: str
) -> dict[str, JsonValue]:
"""Return a new settings dict wired to route Claude Code through the proxy.
Only env.ANTHROPIC_BASE_URL and the top-level apiKeyHelper are overridden; a
stray env.ANTHROPIC_API_KEY is dropped so it cannot outrank the helper-issued
token (same reasoning as build_agent_env in agents.py). Every other key is
preserved untouched.
"""
raw_env: Final = settings.get(ENV_KEY, {})
base_env: Final = raw_env if isinstance(raw_env, dict) else {}
env: Final = {**base_env, ANTHROPIC_BASE_URL_KEY: base_url.rstrip("/")}
env.pop(ANTHROPIC_API_KEY_KEY, None)
return {**settings, ENV_KEY: env, API_KEY_HELPER_KEY: api_key_helper}
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Fix the JSON in the file (root must be an object) or delete it to start fresh.
Example fix
python -m json.tool <path> to find the syntax error.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/client/cli/commands/up.py:59 when the library encounters an invalid state.
Common situations: A `lite up` state file contains invalid JSON or a non-object root.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/43f005e0c1259eb4.
Report an issue: GitHub.