fix(billing): add User-Agent header to fix quota API 403 (WorkBuddy / CodeBuddy / CodeBuddy CN) - #2185
Open
xhrxgr wants to merge 1 commit into
Open
fix(billing): add User-Agent header to fix quota API 403 (WorkBuddy / CodeBuddy / CodeBuddy CN)#2185xhrxgr wants to merge 1 commit into
xhrxgr wants to merge 1 commit into
Conversation
The billing gateway started rejecting requests to
/v2/billing/meter/get-user-resource that carry no User-Agent header:
HTTP 403 {"code":10085,"msg":"请求不合法,请检查请求系统头"}
reqwest sends no User-Agent by default, so quota refresh silently failed
for all WorkBuddy / CodeBuddy / CodeBuddy CN accounts.
The sibling endpoints (get-dosage-notify / get-payment-type) were
unaffected, so only the quota part of the payload went missing: quota_raw
kept "dosage" and "payment" but lost "userResource".
Verified against real accounts: no UA -> 403, empty UA -> 403, any
non-empty UA -> 200 (TotalCount=45). Setting a browser-like UA in
build_client() covers every request these three modules make.
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.
问题
WorkBuddy / CodeBuddy / CodeBuddy CN 的额度(quota)获取全部失效。
账号数据里 6/6 个账号都记录了同一条错误:
根因
计费网关(
/v2/billing/meter/get-user-resource)新增了User-Agent存在性校验,而reqwest默认不发送User-Agent头 → 请求被网关拒绝。用真实账号实测的 UA 矩阵:
{"code":10085,"msg":"请求不合法,请检查请求系统头"}x(任意单字符)code:0,TotalCount:45curl/8.4.0TotalCount:45TotalCount:45即网关只做 UA 存在性校验,任意非空 UA 均可通过。
对照组:同 token、同网关的
get-dosage-notify/get-payment-type仍返回 200(该校验暂未覆盖这两个端点),因此只有额度字段丢失,dosage/payment一切正常——这也是问题表现为"额度没了但其他信息还在"的原因。时间线:最后一次成功
2026-08-31 17:29,首次 4032026-09-01 00:27,属服务端新上线的校验。影响范围
get-user-resource在三处被调用,三个平台均受影响:src-tauri/src/modules/workbuddy_oauth.rssrc-tauri/src/modules/codebuddy_oauth.rssrc-tauri/src/modules/codebuddy_cn_oauth.rs修复
在三个模块的
build_client()上设置 UA,覆盖这些模块发出的全部请求:与
windsurf_devin_oauth.rs中已有的.user_agent(UA)写法保持一致。验证
cargo check通过,无 error(仅仓库既有的 unused 警告)备注
这是服务端策略变更,任何用
reqwest默认配置请求该端点的客户端都会中招,建议尽快合入。