HKUDS/Vibe-Trading · error · FutuConfigError
invalid Futu config at {path}: {exc}
Error message
invalid Futu config at {path}: {exc} What it means
Raised by load_config when the Futu config file exists but cannot be read or parsed: OSError on read, or invalid JSON (ValueError/JSONDecodeError), or a value that fails type conversion in from_mapping.
Source
Thrown at agent/src/trading/connectors/futu/sdk.py:198
cfg = FutuConfig.from_mapping(base)
clean = {k: v for k, v in dict(overrides or {}).items() if k in _OVERRIDE_KEYS and v not in (None, "")}
return cfg.with_overrides(**clean) if clean else cfg
def config_path() -> Path:
"""Return the user-level Futu config path."""
return get_runtime_root() / CONFIG_FILENAME
def load_config() -> FutuConfig:
"""Load Futu settings from ``~/.vibe-trading/futu.json``."""
path = config_path()
if not path.exists():
return FutuConfig()
try:
return FutuConfig.from_mapping(json.loads(path.read_text(encoding="utf-8")))
except (OSError, ValueError, json.JSONDecodeError) as exc:
raise FutuConfigError(f"invalid Futu config at {path}: {exc}") from exc
def save_config(config: FutuConfig) -> Path:
"""Persist Futu settings with owner-only permissions."""
path = config_path()
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(asdict(config), indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
try:
path.chmod(0o600)
except OSError:
pass
return path
def futu_available() -> bool:
"""Return whether the optional ``futu-api`` SDK can be imported."""
try:
_require_futu()View on GitHub (pinned to 80ffdda44c)
Solutions
- Run the file through a JSON validator / json.tool to find the syntax error
- Fix or regenerate the config file
- Ensure 'port' is a number and fields match the expected schema
Example fix
// before
{ "profile": "paper", "port": "11111", } // trailing comma
// after
{ "profile": "paper", "port": 11111 } Defensive patterns
Strategy: try-catch
Validate before calling
import json, pathlib
p = config_path()
if p.exists():
json.loads(p.read_text()) # dry-run parse before the SDK does Try / catch
try:
cfg = load_config()
except FutuConfigError as exc:
logger.error('bad futu config: %s', exc)
cfg = FutuConfig() # fall back to defaults or prompt re-setup Prevention
- Validate config JSON in CI or at app startup
- Write configs programmatically (save_config) rather than by hand
- Keep a schema check for port/host types
When it happens
Trigger: Malformed JSON in the futu config file (trailing comma, single quotes), unreadable file permissions, or non-numeric 'port' value.
Common situations: Hand-edited config with JSON syntax errors, file corrupted, port accidentally quoted as string in a way int() rejects, partial write/ interruption.
Related errors
- invalid Tiger config at {path}: {exc}
- invalid Trading 212 config at {path}: {exc}
- Feishu QR login requires a JSON agent config; use ~/.vibe-tr
- agent config 'channels' must be an object
- agent config 'channels.feishu' must be an object
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/8eb1bc3f7adbd871.
Report an issue: GitHub.