{"record":{"id":"7bdcf5f8c0543fbc","repo":"HKUDS/Vibe-Trading","slug":"tushare-token-not-in-agent-env-or-environment-re","errorCode":null,"errorMessage":"TUSHARE_TOKEN not in agent/.env or environment; required for csi300 universe","messagePattern":"TUSHARE_TOKEN not in agent/\\.env or environment; required for csi300 universe","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/src/tools/alpha_bench_tool.py","lineNumber":318,"sourceCode":"    \"AAPL\", \"MSFT\", \"NVDA\", \"GOOGL\", \"AMZN\", \"META\", \"TSLA\", \"BRK-B\",\n    \"JPM\", \"JNJ\", \"V\", \"PG\", \"UNH\", \"MA\", \"HD\", \"XOM\", \"LLY\", \"MRK\",\n    \"PEP\", \"KO\", \"ABBV\", \"AVGO\", \"CVX\", \"WMT\", \"COST\", \"ADBE\", \"MCD\",\n    \"CRM\", \"ACN\", \"BAC\", \"TMO\", \"ORCL\", \"CSCO\", \"ABT\", \"WFC\", \"DHR\",\n    \"VZ\", \"PFE\", \"INTC\", \"DIS\", \"CMCSA\", \"AMD\", \"TXN\", \"PM\", \"QCOM\",\n    \"NEE\", \"RTX\", \"HON\", \"T\", \"IBM\",\n]\n\n\ndef _load_csi300_panel(start: str, end: str) -> dict[str, pd.DataFrame]:\n    \"\"\"CSI 300 panel via Tushare. Includes ``amount`` (required by gtja191).\n\n    Constituents are taken from the most recent ``index_weight`` snapshot in\n    the requested window; if that call fails we degrade to a 30-name\n    blue-chip fallback so the bench still runs.\n    \"\"\"\n    token = get_env_config().data.tushare_token.strip()\n    if not token or token == \"your-tushare-token\":\n        raise RuntimeError(\n            \"TUSHARE_TOKEN not in agent/.env or environment; required for csi300 universe\"\n        )\n\n    try:\n        import tushare as ts\n    except ImportError as exc:\n        raise RuntimeError(f\"tushare not installed: {exc}\") from exc\n\n    pro = ts.pro_api(token)\n    sd = start.replace(\"-\", \"\")\n    ed = end.replace(\"-\", \"\")\n\n    codes: list[str] = []\n    constituent_source = \"tushare index_weight\"\n    constituent_source_date: str | None = None\n    membership: pd.DataFrame | None = None\n    try:\n        # Reach back before ``start`` so the snapshot that was in force on the","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/tools/alpha_bench_tool.py#L300-L336","documentation":"The csi300 universe pulls constituents from Tushare, which requires a token. This RuntimeError fires when the configured tushare_token is empty or still the placeholder 'your-tushare-token' from agent/.env.","triggerScenarios":"Calling _load_universe_panel(universe='csi300', ...) with no TUSHARE_TOKEN in the environment and an unset/placeholder value in agent/.env.","commonSituations":"Fresh clones that copy .env.example without filling values; CI environments without secrets; tokens named differently (TUSHARE_API_KEY) so the config lookup misses.","solutions":["Set TUSHARE_TOKEN in agent/.env or the shell environment with a real token from tushare.pro","Ensure the value is non-empty and not the literal 'your-tushare-token'","Register a Tushare account with enough points for index_weight/adj_factor access"],"exampleFix":"# agent/.env\n# before\nTUSHARE_TOKEN=your-tushare-token\n# after\nTUSHARE_TOKEN=<real-token-from-tushare.pro>","handlingStrategy":"validation","validationCode":"from src.config import get_env_config\ntok = get_env_config().data.tushare_token.strip()\nassert tok and tok != 'your-tushare-token', 'set TUSHARE_TOKEN in agent/.env'","typeGuard":"def has_tushare_token() -> bool:\n    tok = get_env_config().data.tushare_token.strip()\n    return bool(tok) and tok != 'your-tushare-token'","tryCatchPattern":"try:\n    _load_csi300_panel(s, e)\nexcept RuntimeError as e:\n    if 'TUSHARE_TOKEN' in str(e):\n        prompt_user_for_token(); return","preventionTips":["Fail fast on placeholder .env values at app startup","Keep real tokens out of git; use env injection in CI"],"tags":["config","env-var","credentials","tushare"],"backgroundTag":"missing-api-token","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}