Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/repository/error-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,24 @@ const DEFAULT_ERROR_RULES = [
},
},
},
// Issue #541: Codex model reasoning effort mismatch
{
pattern: "Unsupported value.*is not supported with.*model.*Supported values",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current regex pattern is a bit broad and could potentially match other unrelated error messages, leading to incorrect error handling. It's better to make it more specific to the exact error format to increase robustness and prevent future false positives. This can be done by explicitly matching the quotes and punctuation from the example error message.

Suggested change
pattern: "Unsupported value.*is not supported with.*model.*Supported values",
pattern: "Unsupported value: '.*' is not supported with the '.*' model\\. Supported values are: '.*'\\.",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[High] [LOGIC-BUG] Regex pattern is too broad and can misclassify unrelated “Unsupported value” errors

Evidence (src/repository/error-rules.ts:710):

pattern: "Unsupported value.*is not supported with.*model.*Supported values",

…and the override message is reasoning-effort specific (src/repository/error-rules.ts:721-722).

Why this is a problem: That error string format is generic (many OpenAI/Codex invalid_request_error cases use “Unsupported value … Supported values …”). With the current pattern, unrelated unsupported-value errors (e.g. other params) will be overridden with a reasoning_effort troubleshooting message, hiding the real cause and misleading users.

Suggested fix (tighten the regex to require a reasoning-effort signal from the upstream body):

{
  // ...
  pattern:
    "(\\\"param\\\"\\s*:\\s*\\\"reasoning_effort\\\"|reasoning_effort).*Unsupported value.*is not supported with.*model.*Supported values",
  category: "thinking_error",
  // ...
}

category: "thinking_error",
description: "Reasoning effort (thinking intensity) not supported by the Codex model",
matchType: "regex" as const,
isDefault: true,
isEnabled: true,
priority: 72,
overrideResponse: {
type: "error",
error: {
type: "thinking_error",
message:
"当前思考强度不支持该模型,请调整 reasoning_effort 参数或切换模型(如 'high' 仅支持部分模型)",
},
},
},
Comment on lines +708 to +725
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# 查看文件大小和结构
wc -l src/repository/error-rules.ts

Repository: ding113/claude-code-hub

Length of output: 100


🏁 Script executed:

# 查看 708-725 行的代码
sed -n '700,730p' src/repository/error-rules.ts | cat -n

Repository: ding113/claude-code-hub

Length of output: 1026


🏁 Script executed:

# 查看周围的错误规则以验证优先级顺序
sed -n '690,740p' src/repository/error-rules.ts | cat -n

Repository: ding113/claude-code-hub

Length of output: 1670


🏁 Script executed:

# 搜索所有 thinking_error 分类的规则及其优先级
rg -n --type ts 'thinking_error' src/repository/error-rules.ts -B5 -A10

Repository: ding113/claude-code-hub

Length of output: 2242


🏁 Script executed:

# 搜索 reasoning_effort 相关的代码
rg -n --type ts 'reasoning_effort' --max-count=20

Repository: ding113/claude-code-hub

Length of output: 2843


🏁 Script executed:

# 检查是否有其他 Codex 或思维强度相关的错误规则
rg -n --type ts 'Codex|reasoning.*effort' src/repository/error-rules.ts -B2 -A2

Repository: ding113/claude-code-hub

Length of output: 593


🏁 Script executed:

# 检查第 722 行的精确字符数
sed -n '722p' src/repository/error-rules.ts | wc -c

Repository: ding113/claude-code-hub

Length of output: 70


🏁 Script executed:

# 查看第 721-723 行的完整内容
sed -n '721,723p' src/repository/error-rules.ts

Repository: ding113/claude-code-hub

Length of output: 165


🏁 Script executed:

# 查找 ClaudeErrorResponse 接口定义
rg -n --type ts 'interface ClaudeErrorResponse|type ClaudeErrorResponse' -A10

Repository: ding113/claude-code-hub

Length of output: 701


🏁 Script executed:

# 搜索所有 thinking_error 类别的规则,看是否有其他需要同步的地方
rg -n 'thinking_error' src/repository/error-rules.ts -B1 -A1

Repository: ding113/claude-code-hub

Length of output: 892


🏁 Script executed:

# 检查周围 70-80 优先级范围内的规则
sed -n '600,730p' src/repository/error-rules.ts | grep -n 'priority'

Repository: ding113/claude-code-hub

Length of output: 215


🏁 Script executed:

# 再确认一下完整的第 722 行内容和缩进情况
sed -n '720,724p' src/repository/error-rules.ts | cat -A

Repository: ding113/claude-code-hub

Length of output: 511


🏁 Script executed:

# 检查是否有其他行也超过了 100 字符限制
awk 'NR>=708 && NR<=725 && length($0) > 100 {print NR": "length($0)" chars - "$0}' src/repository/error-rules.ts

Repository: ding113/claude-code-hub

Length of output: 156


修复行长度超限问题

新增的错误规则实现质量整体良好,但存在一个代码风格违规:

行长度超限:第 722 行有 138 个字符,超过编码规范规定的 100 字符限制。需要拆分长字符串:

建议修复方案
message:
  "当前思考强度不支持该模型,请调整 reasoning_effort 参数或" +
  "切换模型(如 'high' 仅支持部分模型)",

或使用模板字符串分行:

message:
  `当前思考强度不支持该模型,请调整 reasoning_effort 参数或切换模型` +
  `(如 'high' 仅支持部分模型)`,

其他方面正确:2 空格缩进、双引号、尾随逗号、正则模式、分类(thinking_error)、优先级位置(72,介于 71 和下一级之间)、ClaudeErrorResponse 接口格式都符合规范。

🤖 Prompt for AI Agents
In src/repository/error-rules.ts around lines 708 to 725, the message string on
line 722 exceeds the 100-character line length limit; split the long string into
multiple shorter string literals concatenated (or use a template literal broken
into concatenated parts) so no single source line exceeds 100 chars, preserve
the existing double-quote style and trailing comma, keep indentation consistent
with surrounding entries, and ensure the final overrideResponse.message content
remains identical.

];

/**
Expand Down
Loading