{"record":{"id":"366c8c6fabcb6bd6","repo":"HKUDS/Vibe-Trading","slug":"invalid-tiger-config-at-path-exc","errorCode":null,"errorMessage":"invalid Tiger config at {path}: {exc}","messagePattern":"invalid Tiger config at (.+?): (.+?)","errorType":"exception","errorClass":"TigerConfigError","httpStatus":null,"severity":"error","filePath":"agent/src/trading/connectors/tiger/sdk.py","lineNumber":162,"sourceCode":"    cfg = TigerConfig.from_mapping(base)\n    clean = {k: v for k, v in dict(overrides or {}).items() if k in _OVERRIDE_KEYS and v not in (None, \"\")}\n    return cfg.with_overrides(**clean) if clean else cfg\n\n\ndef config_path() -> Path:\n    \"\"\"Return the user-level Tiger config path.\"\"\"\n    return get_runtime_root() / CONFIG_FILENAME\n\n\ndef load_config() -> TigerConfig:\n    \"\"\"Load Tiger settings from ``~/.vibe-trading/tiger.json``.\"\"\"\n    path = config_path()\n    if not path.exists():\n        return TigerConfig()\n    try:\n        return TigerConfig.from_mapping(json.loads(path.read_text(encoding=\"utf-8\")))\n    except (OSError, ValueError, json.JSONDecodeError) as exc:\n        raise TigerConfigError(f\"invalid Tiger config at {path}: {exc}\") from exc\n\n\ndef save_config(config: TigerConfig) -> Path:\n    \"\"\"Persist Tiger settings with owner-only permissions.\"\"\"\n    path = config_path()\n    path.parent.mkdir(parents=True, exist_ok=True)\n    path.write_text(json.dumps(asdict(config), indent=2, ensure_ascii=False) + \"\\n\", encoding=\"utf-8\")\n    try:\n        path.chmod(0o600)\n    except OSError:\n        pass\n    return path\n\n\ndef tigeropen_available() -> bool:\n    \"\"\"Return whether the optional ``tigeropen`` SDK can be imported.\"\"\"\n    try:\n        _require_tigeropen()","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connectors/tiger/sdk.py#L144-L180","documentation":"load_config reads the Tiger settings JSON from config_path() and wraps any OSError, ValueError, or json.JSONDecodeError into TigerConfigError with the offending path. Missing files are not an error (returns an empty TigerConfig); this fires only when the file exists but cannot be read/parsed, or when from_mapping rejects its contents.","triggerScenarios":"Calling load_config when the JSON file at config_path() is malformed (truncated, BOM issues, trailing commas), unreadable due to permissions, or contains values that fail TigerConfig.from_mapping validation (e.g. bad profile).","commonSituations":"Concurrent writes corrupting the config file, manual edits leaving invalid JSON, restrictive file permissions (e.g. root-owned file after running with sudo), or a partially-written file from a crashed save_config.","solutions":["Run python -m json.tool on the config file to locate and fix the JSON syntax error","Fix permissions (chmod 600, chown to the running user) if OSError is the cause","If the error message contains 'profile must be...', correct the profile value per from_mapping rules","As a last resort delete the file (load_config will return defaults) and re-run save_config with valid settings"],"exampleFix":"# before\n$ cat ~/.config/.../tiger.json\n{\"profile\": \"live\", \"tiger_id\": \"123\",,}\n\n# after\n{\"profile\": \"live\", \"tiger_id\": \"123\"}","handlingStrategy":"try-catch","validationCode":"import json\nfrom pathlib import Path\n\ndef config_loads(path: Path) -> bool:\n    if not path.exists():\n        return True  # absent file is fine\n    try:\n        json.loads(path.read_text(encoding='utf-8'))\n        return True\n    except (OSError, ValueError):\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    cfg = load_config()\nexcept TigerConfigError as exc:\n    logger.warning('Tiger config unreadable (%s); falling back to defaults', exc)\n    cfg = TigerConfig()  # or quarantine the bad file and re-create it","preventionTips":["Write config atomically (temp file + rename) inside save_config","Keep the config file owner-only and avoid editing it while the app runs","Back up the JSON before manual edits and validate with json.tool"],"tags":["tiger","config","json","file-io"],"backgroundTag":"config-file-parse-error","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}