fix(cliproxy): 对齐 /v0/management/logs 真实契约,修复部署后 502#200
Merged
Conversation
CLIProxyAPI 真实接口契约:
- 查询参数为 limit + after(Unix 秒),不是 since(ISO 字符串)
- 响应为 { lines: string[], "line-count": number, "latest-timestamp": number },不是日志条目数组
- 上游要求 LoggingToFile 启用,否则返回 400
对此做端到端对齐:
- CliproxyLogEntry 类型替换为 CliproxyLogsResult / CliproxyLogsQuery,service / route / hook / panel 全部跟改
- 管理 API 客户端读上游错误正文并拼到 CliproxyManagementApiError.message,让 LoggingToFile 关闭等具体原因能透传到 502 响应
- 日志面板改为渲染原始日志行字符串,按行内关键字(ERROR / WARN / INFO / DEBUG)启发式上色
- 测试同步:management-client / instance-logs-service / logs API route / use-cliproxy / logs panel 全部对齐新契约,并新增 400 错误正文透传断言
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #200 +/- ##
==========================================
+ Coverage 74.41% 74.44% +0.02%
==========================================
Files 160 160
Lines 11595 11624 +29
Branches 3965 3980 +15
==========================================
+ Hits 8628 8653 +25
- Misses 1727 1731 +4
Partials 1240 1240
🚀 New features to boost your workflow:
|
4 tasks
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.
Summary
部署后 GET /api/admin/cliproxy/instances/:id/logs 返回 502。经 deepwiki 核对 CLIProxyAPI 源码,真实接口契约与本仓库实现不一致:
limit+after(Unix 秒),不是since(ISO 字符串){ lines: string[], "line-count": number, "latest-timestamp": number },不是日志条目数组LoggingToFile,否则返回 400(被 AutoRouter 客户端原样吞掉再映射成 502,错误原因丢失)Changes
CliproxyLogEntry替换为CliproxyLogsResult/CliproxyLogsQuery,service / route / hook / panel 全部跟改CliproxyManagementApiError.message,让 "logging to file is disabled" 等具体原因能透传给用户Test plan
Fixes 部署后观察到的
GET /api/admin/cliproxy/instances/<id>/logs 502。