OAuth: non-interactive deployment discards a valid saved account when multiple accounts are authorized

未关闭
#699 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@pcbeingused333 已经在做这个了。

开始于 2026年11月4日。

  • #711 来自 @pcbeingused333 —— 未关闭

评估

难度
3/5
预计耗时
半天
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

The bug is in the OAuth account handling in lean/models/json_module.py, which drops a saved account when several accounts are authorized, even with interactive=False. Start from that account-selection logic and the config_build path that reports the missing --example-account option. Done when a valid saved account survives multiple authorized accounts, an invalid saved account is still discarded, and an explicit command-line account still overrides the saved one, with regression tests covering all three.

由索引模型根据 Issue 内容生成。

描述

Problem

A non-interactive OAuth brokerage configuration rejects a valid account saved in lean.json whenever the authorization returns more than one account.

In lean/models/json_module.py, the OAuth account handling removes the saved account when either it is absent from the returned list or the list has more than one account. The latter condition applies even with interactive=False. Configuration then reports the account option as missing.

Reproduction

Use an OAuth module with an account choice filtered on its OAuth configuration, and:

  • saved configuration: {"project-id": 123, "example-user-name": "SampleUser", "example-account": "ACCOUNT1"};
  • authorization account ids: ["ACCOUNT1", "ACCOUNT2"];
  • config_build(..., interactive=False), without an explicit account command-line option.

Observed: You are missing the following option: --example-account.

Expected: preserve ACCOUNT1, which is explicitly configured and is in the authorized account list.

Confirmed with a synthetic authorization on master 9479601 as well as 42fbdbd. Passing the same account explicitly as a command-line option succeeds on both. This is existing shared OAuth behavior, not specific to a newly added brokerage.

Suggested fix

Only discard a saved account when it is no longer authorized. If interactive mode intentionally asks users to choose again when several accounts are available, keep that policy confined to interactive mode. Add regression coverage for a valid saved account with multiple authorized accounts, an invalid saved account, and an explicit command-line override.

主要语言
Python
星标
330
派生
171
平均合并
2 天 21 小时
30 天内合并 PR
18

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

QuantConnect/lean-cli 的其他 Issue

查看 QuantConnect/lean-cli 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。