Skip to content

fix(workbuddy): 修 camelCase 并支持 workbuddy-accounts 批量导入 - #393

Merged
caigee-cmd merged 3 commits into
mainfrom
fix/workbuddy-accounts-import
Oct 25, 2026
Merged

caigee-cmd merged 3 commits into
mainfrom
fix/workbuddy-accounts-import

Conversation

@caigee-cmd

Copy link
Copy Markdown
Owner

结论

修复 WorkBuddy 凭证导入:camelCase 解码 bug、识别 hub 整包 workbuddy-accounts、支持批量导入(partial success)。请 review 后自行 merge,本 PR 不自动合入。

根因

  1. DecodeCredential 的 flat camelCase 分支写成了 err != nil,单条 hub accounts[i](camelCase)会报 requires access_token。
  2. 控制层只认 workbuddy-oauth-v1,workbuddy-accounts → unsupported_format。
  3. 前端 runImport 一次只打一条,且有 format 时不会改写成可识别格式。

改动

  • credential.go:err != nil → err == nil;新增 AccountsFormat。
  • import.go:SplitImport 解开 accounts[];PrepareImport Decode→Encode 规范为 snake_case,Ready 正确。
  • registry:CredentialFormats 增加 workbuddy-accounts alias。
  • control:ImportAll 逐条 Prepare+建账号;失败策略 partial success(能过的留下,汇总成功/失败,不静默丢条);存储格式仍为 workbuddy-oauth-v1。
  • console:单条仍返回账号 201;多条/有失败返回 import_result。
  • 前端:导入 Tab 可贴整包;提示成功 N / 失败 M(含失败摘要)。

失败策略

选择 partial success + 清晰汇总:非法/失败条目记入 errors[],已成功账号不回滚。与账号池「尽量可用」语义一致。

测试

  • go test ./internal/providers/workbuddy/ ./internal/control/ ./internal/console/
  • 覆盖:camel Decode/PrepareImport;accounts 1 条与 N 条;坏条目报 accounts[i];控制层 alias / 批量 / 跳过坏条。

手动验证

  1. 从 workbuddy2api-hub 导出(假 token 即可测格式)。
  2. 控制台 → 添加账号 → WorkBuddy → 导入 Tab,粘贴整包 JSON。
  3. 期望:多条全部创建;若夹杂坏条,提示成功 N / 失败 M。
  4. 单条 camelCase / snake_case / nested {account,auth} 仍可导入。

不做

  • 不 merge、不发版、不动 SGP3 / chat 指纹 / 签到调度 / WorkBuddy #643。
  • 单测与提交不含真实 JWT。

Fix DecodeCredential camelCase branch (err == nil), accept
workbuddy-accounts hub exports, and import every accounts[] entry with
partial-success reporting. Console keeps the single-account response
shape; multi-account imports return an import_result summary.
@caigee-cmd
caigee-cmd merged commit a57861a into main Oct 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant