Repository navigation
fix(logging): add request IDs to SDK 2.0 response errors - #224
Merged
Merged
Conversation
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.
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
参考 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 参数数量告警,未修改配置或忽略规则。