Skip to content

deploy deploy --mode live 非法 account 抛裸 1054 SQL 异常 #6281

Description

@Kaoruha

What to build

ginkgo deploy deploy --mode live --account <不存在的account_id> 当前把底层 ORM 异常直接抛给用户:pymysql.err.OperationalError (1054, Unknown column 'portfolio.live_account_id AS portfolio_live_account_id')

应在部署校验阶段对 account_id 做"存在性 + 合法性"预检,account 不存在时优雅返回业务错误(如"实盘账户不存在: "),而非裸 SQL 异常。

注:1054 Unknown column 同时可能是 DB 漂移(create_all 不加列,见 arch_create_all_no_alter_drift)——即 portfolio.live_account_id 列在旧 Test 库缺失。代码层修优雅兜底;环境层若为漂移需重建 DB。两层都请核对。

Steps to reproduce

  1. ginkgo deploy deploy <any_pid> --mode live --account "fake_nonexistent_uuid"
  2. 观察:输出裸 MySQL session error (pymysql.err.OperationalError) (1054, Unknown column 'portfolio.live_account_id ...'),退出码非 0 但无业务错误文案。
  3. 对照:deploy deploy <pid> --mode live(不带 account)正确返回"实盘模式需要 --account 参数"。

Expected behavior

传入不存在/非法 account_id 时,CLI 输出清晰业务错误(如 实盘账户不存在: fake_nonexistent_uuid),不暴露 SQL/ORM 堆栈。若根因是列缺失(DB 漂移),在文档/错误中指引用户重建 DB。

Acceptance criteria

  • account_id 不存在时返回业务错误而非裸 1054
  • broker_instance_crud.get_broker_by_live_account 的查询在列缺失时也能被上层 try/except 兜底
  • 核对 portfolio 表是否有 live_account_id 列;若为漂移,记录重建步骤
  • 新增测试:非法 account_id 的 deploy live 返回业务错误

Blocked by

None - can start immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: needed for next releasebugSomething isn't workingmod:liveLive trading (livecore, broker, gateway)mod:tradingTrading (engines, strategies, risk, brokers)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions