{"record":{"id":"224119646edacbf6","repo":"HKUDS/Vibe-Trading","slug":"tiger-private-key-not-found-at-key-path","errorCode":null,"errorMessage":"Tiger private key not found at {key_path}","messagePattern":"Tiger private key not found at (.+?)","errorType":"exception","errorClass":"TigerConfigError","httpStatus":null,"severity":"critical","filePath":"agent/src/trading/connectors/tiger/sdk.py","lineNumber":565,"sourceCode":"\n\ndef _require_tigeropen() -> ModuleType:\n    try:\n        import tigeropen  # type: ignore\n    except ModuleNotFoundError as exc:\n        raise TigerDependencyError(\"tigeropen is not installed; run `pip install tigeropen`.\") from exc\n    return tigeropen\n\n\ndef _client_config(cfg: TigerConfig):\n    \"\"\"Build a ``TigerOpenClientConfig`` from connector settings.\"\"\"\n    _require_tigeropen()\n    from tigeropen.common.util.signature_utils import read_private_key  # type: ignore\n    from tigeropen.tiger_open_config import TigerOpenClientConfig  # type: ignore\n\n    key_path = Path(cfg.private_key_path).expanduser()\n    if not key_path.exists():\n        raise TigerConfigError(f\"Tiger private key not found at {key_path}\")\n    client_config = TigerOpenClientConfig()\n    client_config.private_key = read_private_key(str(key_path))\n    client_config.tiger_id = cfg.tiger_id\n    client_config.account = cfg.account\n    try:\n        client_config.timeout = cfg.timeout\n    except Exception:  # noqa: BLE001 - older SDKs may not expose timeout\n        pass\n    return client_config\n\n\ndef _trade_client(cfg: TigerConfig):\n    _require_tigeropen()\n    from tigeropen.trade.trade_client import TradeClient  # type: ignore\n\n    return TradeClient(_client_config(cfg))\n\n","sourceCodeStart":547,"sourceCodeEnd":583,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connectors/tiger/sdk.py#L547-L583","documentation":"_client_config expands cfg.private_key_path and requires the file to exist before calling tigeropen's read_private_key. A missing key file is classified as TigerConfigError rather than an auth failure, because the connector treats key material location as configuration. The path is used exactly as configured (with ~ expansion but no search of default locations).","triggerScenarios":"Calling any function that builds a Tiger client (_trade_client, _quote_client -> _client_config) when cfg.private_key_path points to a nonexistent path — typo, unexpanded env var, absolute path valid only on another machine, or key file never downloaded from Tiger's developer portal.","commonSituations":"Config written on a dev machine with a home-relative path that differs in deployment; SSH key generated but saved elsewhere; container lacking the mounted secret; path containing '$HOME' literally instead of '~' or an expanded absolute path.","solutions":["Verify the path: ls -l the exact expanded value of cfg.private_key_path","Download/regenerate the RSA private key from the Tiger OpenAPI portal and place it at the configured path","Use an absolute path or '~' (expanduser is applied) rather than '$HOME' or relative paths","In containers, ensure the key is mounted/secret-injected before the connector starts"],"exampleFix":"# before\n{\"private_key_path\": \"/home/dev/keys/tiger.pem\"}  # missing on server\n\n# after\n{\"private_key_path\": \"/etc/vibetrading/secrets/tiger_private_key.pem\"}","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef key_present(cfg) -> bool:\n    return bool(cfg.private_key_path) and Path(cfg.private_key_path).expanduser().is_file()","typeGuard":"def has_valid_key_path(cfg: TigerConfig) -> bool:\n    p = Path(cfg.private_key_path or '').expanduser()\n    return p.is_file() and p.stat().st_size > 0","tryCatchPattern":"try:\n    positions = get_positions(cfg)\nexcept TigerConfigError as exc:\n    if 'private key not found' in str(exc):\n        logger.error('Missing Tiger key at %s — mount/regenerate it', cfg.private_key_path)\n    raise","preventionTips":["Use absolute paths for key material in deployed configs","Add a preflight check at startup that all configured key files exist and are readable","Mount secrets into the container before app start and verify in a health check"],"tags":["tiger","private-key","config","file-not-found"],"backgroundTag":"private-key-file-missing","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}