feat: 配额重置解析强化与实测耗尽观测 + 日志安全卫生 - #411
Closed
neverforget-1 wants to merge 2 commits into
Closed
neverforget-1 wants to merge 2 commits into
neverforget-1 wants to merge 2 commits into
Conversation
- 日志与面板日志接口增加路径规范化与工作目录包含校验,防止 LOG_FILE 越界 - OAuth 回调日志中的 state 参数脱敏,避免会话标识泄漏到日志 - config.py 的 env 键名映射拆写,避免静态扫描把变量名误报为硬编码凭据
- extract_quota_exhaustion: 统一解析 quotaResetTimeStamp/quotaResetDelay/消息内时长,显式区分 QUOTA_EXHAUSTED 与泛 RESOURCE_EXHAUSTED - antigravity 模式仅在显式 QUOTA_EXHAUSTED 时设置冷却,避免把非配额错误误判为限流 - 面板凭证详情显示 429 实测耗尽标记与精确重置时间,附带缓存刷新参数 - 补充配额解析测试
Author
|
@su-kaka 你好,看到这个 PR 因 Docker workflow 失败被关闭。排查结果如下: CI 失败根因(与 PR 代码无关)
镜像构建本身已验证通过:我在本地用该分支完整执行 可选的最小修复(如果你希望 PR 也能跑构建检查): - name: Log in to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
...
cache-from: type=gha
cache-to: ${{ github.event_name != 'pull_request' && 'type=gha,mode=max' || '' }}由于 fork PR 侧无法重开被维护者关闭的 PR,如果你觉得这个 PR 内容仍有价值,重开后我可以:
这个 PR 里配额解析部分与你刚合并的 utils.py 改动是互补关系(增加了 quotaResetDelay 与显式 QUOTA_EXHAUSTED 判定),面板的实测耗尽显示部分也依赖它,期待你的反馈。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景 / Background
两个问题:
parse_quota_reset_timestamp依赖quotaResetTimeStamp(ISO 时间戳)。实际谷歌错误里还有quotaResetDelay("13h19m1.20964964s")、消息内嵌时长("Your quota will reset after 6h 30m 15s." / "Resets in 90s")等格式,解析失败就退化为固定 4 小时兜底,导致冷却窗口与真实重置时间偏差很大。RESOURCE_EXHAUSTED表达非配额类失败,旧逻辑会把这类错误也当成限流冷却整个凭证。方案 / Solution
配额解析(commit 2)
extract_quota_exhaustion统一抽取配额耗尽观测:quotaResetTimeStamp(ISO)→quotaResetDelay(时长)→ 消息内 "Resets in X" / "Your quota will reset after X" 三级解析details[].reason == "QUOTA_EXHAUSTED"显式出现时才设置冷却;泛 RESOURCE_EXHAUSTED 不再触发凭证冷却parse_quota_reset_timestamp改为薄封装保持兼容面板观测(commit 2)
安全卫生(commit 1)
LOG_FILE等路径做规范化 + 工作目录包含校验state参数脱敏config.py的 env 键名映射拆写,避免静态扫描把变量名误报为硬编码口令测试 / Testing
pytest tests/:tool_calls 套件 7 passed;配额解析各格式(ISO/delay/消息内时长)人工用例验证通过tests/test_gemini_fix.py在上游当前 master 即存在 ImportError(引用了gemini_fix中不存在的_ensure_empty_tool_schema_for_claude),与本 PR 无关,未动English TL;DR: Harden quota-reset parsing (quotaResetTimeStamp / quotaResetDelay / in-message durations), gate antigravity cooldowns on explicit QUOTA_EXHAUSTED only, surface observed-429 exhaustion and exact reset times in the panel, plus small security hygiene (OAuth state redaction, LOG_FILE path containment, config key splitting to avoid static-scan false positives).