HKUDS/Vibe-Trading · error · ValueError
each local connection must be an object
Error message
each local connection must be an object
What it means
Raised while parsing persisted local-connection settings: an entry in the connections list is not a JSON object (e.g. it is a string, number, list, or null). _parse expects each serialized connection to be a dict with id/profile_id/label keys, so any other JSON value is rejected before field validation begins.
Source
Thrown at agent/src/trading/connections.py:303
return result
@staticmethod
def _parse(raw: object) -> TradingConnection:
"""Validate one registry row.
Args:
raw: Decoded registry row.
Returns:
The validated connection.
Raises:
ValueError: If the row is not an object, carries an invalid id or
label, names an unknown or ineligible profile, or claims a
credential reference that does not match its transport.
"""
if not isinstance(raw, dict):
raise ValueError("each local connection must be an object")
connection_id = str(raw.get("id") or "").strip().lower()
if not _ID_RE.fullmatch(connection_id):
raise ValueError(f"invalid local connection id: {connection_id or '?'}")
profile_id = str(raw.get("profile_id") or "").strip().lower()
profile = profile_by_id(profile_id)
if not is_portfolio_connection_profile(profile):
raise ValueError(
f"connection profile is not eligible for read-only portfolios: {profile_id}"
)
label = str(raw.get("label") or profile.label).strip()
if (
not label
or len(label) > 80
or any(ord(character) < 32 for character in label)
):
raise ValueError(
"connection label must contain 1 to 80 printable characters"
)View on GitHub (pinned to 80ffdda44c)
Solutions
- Open the settings file and make every element of the connections array a JSON object with at minimum id and profile_id
- Remove stray/legacy non-object entries, then re-add them properly via store.create()
- If the file is corrupted, back it up and let the store recreate a fresh one
- Validate the file with a JSON schema or json.load plus an isinstance(item, dict) check before handing it to the store
Example fix
// before
{"connections": ["alpaca"]}
// after
{"connections": [{"id": "alpaca", "profile_id": "paper", "label": "Alpaca paper"}]} Defensive patterns
Strategy: validation
Validate before calling
import json
data = json.loads(path.read_text())
entries = data.get("connections", [])
if not all(isinstance(e, dict) for e in entries):
raise ValueError("connections list contains non-object entries") Type guard
def is_connection_object(raw: object) -> bool:
return isinstance(raw, dict) Try / catch
try:
store.list()
except ValueError as exc:
if "must be an object" in str(exc):
# locate and fix/remove the offending entry, then retry
... Prevention
- Only mutate connection settings through the store API, never a text editor
- Lint settings files after manual edits with a small schema check
- Back up settings before migrations that rewrite the connections array
When it happens
Trigger: Calling list() or save() on a store whose loaded settings contain a non-dict element in the connections array — e.g. ["alpaca", {...}], [null], or a bare string entry edited by hand.
Common situations: Hand-editing the connections settings file and accidentally leaving a stray string or comment-like entry; a partially written/corrupted settings file after a crash; migrating from an older format that allowed shorthands like plain connection names.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- invalid Alpaca config at {path}: {exc}
- invalid hypotheses storage JSON: {self.path}
- hypotheses storage must contain a JSON list
- sources must be a list
- each portfolio source must be an object
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/b07a2c72dbabe25e.
Report an issue: GitHub.