Refactor chaterror.Classify to normalize evidence gathering
还没有人认领这个 Issue。
评估
调研方向
从 coderd/x/chatd/chaterror/classify.go 开始,然后阅读 signals.go 和 provider_error.go,以追踪当前如何收集和显示 transport 与结构化响应文本。运行现有的 chaterror signal 测试,然后统一证据来源,并添加 issue 中描述的仅 body/仅 transport 矩阵;完成的标准是所有 signal 无论来源如何都能得到一致分类,同时不改变 Classify 的公开签名。
由索引模型根据 Issue 内容生成。
描述
Note: this issue was filed by an over-eager agent with too many MCP tools.
Context
PR coder/coder#27913 fixed a bug where a Bedrock credential resolution failure was incorrectly retried as a generic 500. The fix widened several signal checks in chaterror.Classify to read combinedText (the merged transport wrapper + structured response body) instead of lower (just the wrapper).
This exposed a structural issue: the classifier has two parallel text sources (lower from err.Error() and structured.detail from ProviderError.ResponseBody) and signal checks inconsistently pick which to match against. PR coder/coder#27913 widened the body-only signals, but the underlying design is fragile.
Problems
-
Two-source inconsistency: Some signals check
lower, some checkcombinedText, and it is unclear which uses which without reading each line. New signal checks can silently regress tolower-only. -
Pattern sprawl: Too many string patterns across too many signal lists (
overloadedPatterns,authStrongPatterns,configPatterns,timeoutPatterns, etc.) without documentation of which provider incident motivated each pattern. -
Signal/display coupling:
structured.detail(used for signal matching) is the first line of the response body only (providerErrorResponseMessagetruncates at the first newline). If the useful signal text appears on line 2+, it is missed. The signal source and the user-facing detail display are the same string; they should be decoupled.
Proposed approach
Data-flow normalization, not a rule engine:
- One
gatherEvidencestep at the top ofClassifythat produces a single struct: lowercased combined text (transport error + full structured body, not just first line), status code, and any structured provider fields. - Every signal check reads only from the evidence struct. No signal touches raw inputs.
- Keep the prioritized rule ordering as plain Go code. Do not build a pattern-matching DSL or data-driven rule table.
- Decouple signal matching text from user-facing detail display text.
Non-goals
- No new error taxonomy.
- No change to
Classify's public signature. - No pattern DSL or data-driven rule engine.
Test strategy
Convert signal tests to a matrix that programmatically asserts each source-agnostic signal classifies correctly when the pattern arrives via body-only and via transport-only. This makes "forgot to check the other source" impossible to reintroduce silently.
Related
- PR coder/coder#27913 (the incremental fix)
coderd/x/chatd/chaterror/classify.go(the classifier)coderd/x/chatd/chaterror/signals.go(the pattern definitions)coderd/x/chatd/chaterror/provider_error.go(response body extraction)
- 主要语言
- 没有语言数据
- 星标
- 3
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/internal 的其他 Issue
-
flake
难度 2/5 1-3 小时 新手友好度 72/100
-
chore: cleanup http transport debt可能已有人在做 @sreya 于 4 天前认领。 未关闭
-
flake: TestPubsubCluster/ClusterAuthRequired可能重新可做 @sreya 于 54 天前认领,目前没有进行中的 PR。 未关闭flake
-
flake
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
SciML/Evolutionary.jl#182 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
simonw/llm-mistral#43 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
rossoctl/context-guru#346 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
prime-radiant-inc/evener#2883 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
GoogleChromeLabs/project-sesame#216 ·
维护者通常 12 天内回复