Skip to content

fix(logging): add request IDs to SDK 2.0 response errors - #224

Merged
luk384090-cloud merged 4 commits into
mainfrom
dev/request-id-logging
Nov 9, 2026
Merged

luk384090-cloud merged 4 commits into
mainfrom
dev/request-id-logging

Conversation

@lzsweb

@lzsweb lzsweb commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

参考 dashscope/dashscope-sdk-java#285,仅补齐 Python SDK 2.0 请求相关日志的 request_id:HTTP 响应读取/解析与业务错误,SSE 解析/业务错误,以及 WebSocket 握手、断线、task-failed 和 ASR/TTS 会话运行错误。

支持三种响应头 ID 别名,保留 body/output/header 优先级和已知流/任务上下文。共享 WebSocket 按任务隔离日志 ID,不污染共享异常;不记录凭据、完整响应或音频数据。

保持非抛异常返回、恢复性错误及主动关闭行为。Job SSE 异常继续仅使用顶层 body.request_id,header ID 只用于日志。未修改 legacy_1x、共享实现、applications、CLI、版本或配置;不迁移 Java PR 的 outputless SSE 过滤与版本调整。

Test plan

已运行 python3 -m pytest tests --ignore=tests/legacy_1x -q:3290 passed,4 skipped。新增同步/异步日志、ID 回退与安全、共享连接任务隔离、生命周期及历史兼容性回归测试,并完成独立复核。

全部改动通过 Black 79 列检查、flake8 和 git diff --check。mypy 未安装,未执行;本机 Pylint 3.3.9 相比仓库固定的 3.0.2 仅报告原有函数的 R0917 参数数量告警,未修改配置或忽略规则。

zhansheng.lzs added 4 commits November 3, 2026 16:35
Preserve response and task request context across HTTP, SSE and audio failures without logging sensitive payloads or changing legacy SDK behavior.
Keep current tests automatic and type the WebSocket error-log fallback so the pinned pre-commit mypy check passes without changing runtime behavior.
Restore the legacy job's original event condition and drop the
workflow_dispatch-only gate, so archived 1.x tests run on push and
non-docs pull requests instead of manual dispatch alone.
ubuntu-latest now resolves to Ubuntu 26.04, which ships no CPython 3.9
build, so setup-python failed on the 3.9 leg. Keep the still-supported
3.9 leg on ubuntu-24.04 and leave 3.10-3.13 on ubuntu-latest, for both
the current and legacy jobs.
@luk384090-cloud
luk384090-cloud merged commit ebe8b5a into main Nov 9, 2026
12 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.

2 participants