Repository navigation
fix(checkin): 正确透传 HTTP 状态与响应,修复 401 刷新并发问题 (#7) - #14
Merged
Merged
Conversation
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.
背景
PR #7(#7,已于 2026-10-22 合并)新增签到代理端点。按仓库维护者的要求,先合并原贡献,再从合并后的
main独立修复 review 中列出的阻断问题,保留原作者贡献和审查历史。修复
GET及POST /v1/checkin-status-> 上游均为 POST/v2/billing/meter/checkin-status,发送空 JSON{};已直连验证 GET 返回 404,POST 返回 200;兼容只支持 POST 的客户端调用。POST /v1/checkin-> 上游 POST/v2/billing/meter/daily-checkin,保持空 JSON 请求体。{status:"ok",upstream:...},包括 400/401/429/5xx、HTML、文本、非 dict JSON 和二进制响应。CodeBuddyClient.refresh()明确刷新,而不是原先不会强制刷新的ensure_authenticated(False);刷新成功且 access token 发生变化后最多重试一次,刷新失败/异常则保留原始 401,记录脱敏错误类型。billing_proxy.py,主代理入口只保留两个极简路由。验证
使用
httpx.MockTransport的 27 个新增接口级回归测试(无需真实账号及上游访问)覆盖:GET/POST 方法和 body、原始响应结构、400/401/429/500/503、HTTP 401 刷新成功/失败/抛错/token 未变、刷新后依然 401 最多两次请求、超时/连接失败、非 JSON 和二进制、局部认证失败、并发三请求共一次 token 刷新。Windows 隔离 worktree 中按如下命令执行:
结果:200 passed, 1 skipped, 1 deselected。唯一排除的
test_backend_profiles.py::test_session_profiles_are_isolated_and_saved_with_metadata测试在 Windows 上将文件 POSIX 权限严格断言为0600,在原主线同环境已失败,与签到实现无关;test_login_headers当前已通过。本 PR 不自动合并,请审查新契约和测试后再合并。原 PR #7 的旧
CHANGES_REQUESTED在“先合并、另开修复 PR”的维护策略下撤销,并不代表旧问题原先已解决。