fix(client): improve API robustness #215

Open
wangyue111 wants to merge 1 commits from wangyue111/gitlink-cli:fix/client-robustness into master
Contributor

背景

这一组修改聚焦 CLI 底层稳定性,而不是新增单点命令。当前所有 Shortcut 和 Raw API 最终都会经过 internal/client 与仓库上下文解析,一旦这里存在边界问题,会影响 Issue、PR、Webhook、批处理等多个功能域。

修改内容

  • 所有 API 请求统一带上 Accept: application/json
  • 带 body 的请求统一设置 Content-Type: application/json
  • 兼容 GitLink API 中 data 字段以 JSON 字符串返回的情况,自动解析为结构化对象
  • PaginateAll 克隆调用方传入的 query,避免分页过程中污染外部参数
  • 仓库 remote 解析时规范化 path segment,修复多余 / 或空路径导致的 owner/repo 误解析

价值

  • 提升所有命令的 API 兼容性和可诊断性
  • 降低 Raw API / Shortcut 在复杂响应结构下的解析成本
  • 修复分页工具的隐藏副作用,减少后续批量功能踩坑
  • 属于共享基础能力修复,收益覆盖全项目

测试

git diff --check
GOPROXY=https://goproxy.cn,direct go test ./internal/client ./internal/context
go vet ./internal/client ./internal/context
GOPROXY=https://goproxy.cn,direct go test ./...
go vet ./...

文档

新增 doc/changes/client-robustness-fixes.md 记录问题背景、修复点和验证方式。

## 背景 这一组修改聚焦 CLI 底层稳定性,而不是新增单点命令。当前所有 Shortcut 和 Raw API 最终都会经过 `internal/client` 与仓库上下文解析,一旦这里存在边界问题,会影响 Issue、PR、Webhook、批处理等多个功能域。 ## 修改内容 - 所有 API 请求统一带上 `Accept: application/json` - 带 body 的请求统一设置 `Content-Type: application/json` - 兼容 GitLink API 中 `data` 字段以 JSON 字符串返回的情况,自动解析为结构化对象 - `PaginateAll` 克隆调用方传入的 query,避免分页过程中污染外部参数 - 仓库 remote 解析时规范化 path segment,修复多余 `/` 或空路径导致的 owner/repo 误解析 ## 价值 - 提升所有命令的 API 兼容性和可诊断性 - 降低 Raw API / Shortcut 在复杂响应结构下的解析成本 - 修复分页工具的隐藏副作用,减少后续批量功能踩坑 - 属于共享基础能力修复,收益覆盖全项目 ## 测试 ```bash git diff --check GOPROXY=https://goproxy.cn,direct go test ./internal/client ./internal/context go vet ./internal/client ./internal/context GOPROXY=https://goproxy.cn,direct go test ./... go vet ./... ``` ## 文档 新增 `doc/changes/client-robustness-fixes.md` 记录问题背景、修复点和验证方式。
wangyue111 force-pushed fix/client-robustness from 35fef13287 to fd816a7240 2026-06-14 23:40:46 +08:00 Compare
wangyue111 force-pushed fix/client-robustness from fd816a7240 to 3a020e7575 2026-06-16 08:19:49 +08:00 Compare
wangyue111 force-pushed fix/client-robustness from 3a020e7575 to 036e835a76 2026-06-22 12:32:08 +08:00 Compare
This pull request has changes conflicting with the target branch.
  • internal/client/pagination.go
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b wangyue111-fix/client-robustness master
git pull fix/client-robustness

Step 2:

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff wangyue111-fix/client-robustness
git push origin master
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#215
No description provided.