Fix #541: Add error rule for Codex reasoning effort mismatch#544
Conversation
Closes #541 This commit adds a new error rule to handle the case when a Codex API provider returns an error due to unsupported reasoning effort (thinking intensity) values for a specific model. Error pattern example: "Unsupported value: 'high' is not supported with the 'gpt-5.2-codex' model. Supported values are: 'medium'." The new error rule: - Pattern: Uses regex to match the "Unsupported value" error format - Category: thinking_error (priority: 72) - Response: Provides a user-friendly Chinese message suggesting to adjust reasoning_effort parameter or switch to a different model 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📝 Walkthrough概览在 变更
评估代码审查工作量🎯 2 (简单) | ⏱️ ~8 分钟 可能相关的 PR
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Summary of ChangesHello @ding113, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances error handling for Codex API interactions by introducing a new default error rule. The rule specifically addresses scenarios where the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new error rule to handle a specific Codex API error for incompatible reasoning_effort values. The change is well-contained and improves the user experience by providing a more informative error message. I have one suggestion to make the regular expression more specific and robust.
| }, | ||
| // Issue #541: Codex model reasoning effort mismatch | ||
| { | ||
| pattern: "Unsupported value.*is not supported with.*model.*Supported values", |
There was a problem hiding this comment.
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.
| pattern: "Unsupported value.*is not supported with.*model.*Supported values", | |
| pattern: "Unsupported value: '.*' is not supported with the '.*' model\\. Supported values are: '.*'\\.", |
🧪 测试结果
总体结果: ✅ 所有测试通过 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
📒 Files selected for processing (1)
src/repository/error-rules.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Use 2-space indentation in all code files
Files:
src/repository/error-rules.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use double quotes for strings instead of single quotes
Use trailing commas in multi-line structures
Enforce maximum line length of 100 characters
Use path alias@/*to reference files from./src/*directory
**/*.{ts,tsx,js,jsx}: Use Biome for linting and formatting with 2-space indent, double quotes, trailing commas, and 100 character max line length
Use path alias@/*to reference files in./src/*directory
Files:
src/repository/error-rules.ts
src/repository/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use Repository pattern in
src/repository/to wrap Drizzle queries
Files:
src/repository/error-rules.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode for type safety
Use readonly or const assertions for immutable data structures
Files:
src/repository/error-rules.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Hash API keys using SHA-256 before storing in database, never store plaintext keys
Mask API keys and sensitive data in application logs
Validate required environment variables at startup with clear error messages
Files:
src/repository/error-rules.ts
src/{repository,actions}/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Avoid N+1 queries by using eager loading and batch queries for statistics
Files:
src/repository/error-rules.ts
🧠 Learnings (1)
📚 Learning: 2026-01-05T03:01:39.354Z
Learnt from: NieiR
Repo: ding113/claude-code-hub PR: 539
File: src/types/user.ts:158-170
Timestamp: 2026-01-05T03:01:39.354Z
Learning: In TypeScript interfaces, explicitly document and enforce distinct meanings for null and undefined. Example: for numeric limits like limitTotalUsd, use 'number | null | undefined' when null signifies explicitly unlimited (e.g., matches DB schema or special UI logic) and undefined signifies 'inherit default'. This pattern should be consistently reflected in type definitions across related fields to preserve semantic clarity between database constraints and UI behavior.
Applied to files:
src/repository/error-rules.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Greptile Review
- GitHub Check: check-codex-status
- GitHub Check: pr-review
- GitHub Check: pr-description
- GitHub Check: pr-label
- GitHub Check: 🌐 API Tests
- GitHub Check: Docker Build Test
- GitHub Check: dev-build-deploy
| // Issue #541: Codex model reasoning effort mismatch | ||
| { | ||
| pattern: "Unsupported value.*is not supported with.*model.*Supported values", | ||
| 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' 仅支持部分模型)", | ||
| }, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# 查看文件大小和结构
wc -l src/repository/error-rules.tsRepository: ding113/claude-code-hub
Length of output: 100
🏁 Script executed:
# 查看 708-725 行的代码
sed -n '700,730p' src/repository/error-rules.ts | cat -nRepository: ding113/claude-code-hub
Length of output: 1026
🏁 Script executed:
# 查看周围的错误规则以验证优先级顺序
sed -n '690,740p' src/repository/error-rules.ts | cat -nRepository: ding113/claude-code-hub
Length of output: 1670
🏁 Script executed:
# 搜索所有 thinking_error 分类的规则及其优先级
rg -n --type ts 'thinking_error' src/repository/error-rules.ts -B5 -A10Repository: ding113/claude-code-hub
Length of output: 2242
🏁 Script executed:
# 搜索 reasoning_effort 相关的代码
rg -n --type ts 'reasoning_effort' --max-count=20Repository: ding113/claude-code-hub
Length of output: 2843
🏁 Script executed:
# 检查是否有其他 Codex 或思维强度相关的错误规则
rg -n --type ts 'Codex|reasoning.*effort' src/repository/error-rules.ts -B2 -A2Repository: ding113/claude-code-hub
Length of output: 593
🏁 Script executed:
# 检查第 722 行的精确字符数
sed -n '722p' src/repository/error-rules.ts | wc -cRepository: ding113/claude-code-hub
Length of output: 70
🏁 Script executed:
# 查看第 721-723 行的完整内容
sed -n '721,723p' src/repository/error-rules.tsRepository: ding113/claude-code-hub
Length of output: 165
🏁 Script executed:
# 查找 ClaudeErrorResponse 接口定义
rg -n --type ts 'interface ClaudeErrorResponse|type ClaudeErrorResponse' -A10Repository: ding113/claude-code-hub
Length of output: 701
🏁 Script executed:
# 搜索所有 thinking_error 类别的规则,看是否有其他需要同步的地方
rg -n 'thinking_error' src/repository/error-rules.ts -B1 -A1Repository: 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 -ARepository: 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.tsRepository: 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.
| }, | ||
| // Issue #541: Codex model reasoning effort mismatch | ||
| { | ||
| pattern: "Unsupported value.*is not supported with.*model.*Supported values", |
There was a problem hiding this comment.
[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",
// ...
}There was a problem hiding this comment.
Code Review Summary
This PR adds a new default error rule intended to translate a Codex reasoning_effort mismatch into a user-friendly message. The current regex is overly generic and can match other “Unsupported value … Supported values …” errors, potentially returning a misleading reasoning_effort message and obscuring the real failure.
PR Size: XS
- Lines changed: 18
- Files changed: 1
Issues Found
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic/Bugs | 0 | 1 | 0 | 0 |
| Security | 0 | 0 | 0 | 0 |
| Error Handling | 0 | 0 | 0 | 0 |
| Types | 0 | 0 | 0 | 0 |
| Comments/Docs | 0 | 0 | 0 | 0 |
| Tests | 0 | 0 | 0 | 0 |
| Simplification | 0 | 0 | 0 | 0 |
Critical Issues (Must Fix)
None
High Priority Issues (Should Fix)
src/repository/error-rules.ts:710[High] [LOGIC-BUG] Regex is too broad and may override unrelated unsupported-value errors with a reasoning_effort-specific message (confidence: 88).
Review Coverage
- Logic and correctness
- Security (OWASP Top 10)
- Error handling
- Type safety
- Documentation accuracy
- Test coverage
- Code clarity
Automated review by Codex AI
There was a problem hiding this comment.
- Identified open PR as
#544and calculated PR Size: XS (18lines changed,1file). - Applied label
size/XSviagh pr edit. - Posted 1 inline review comment on
src/repository/error-rules.ts:710flagging a [High] [LOGIC-BUG]: the new regex is broad enough to override unrelated “Unsupported value … Supported values …” errors with a reasoning-effort-specific message; suggested tightening the pattern to require areasoning_effortsignal (e.g.,"param": "reasoning_effort"in upstream JSON). - Submitted the required review summary using
gh pr review --comment --body ....
Note: the GitHub API in this environment rejected line/side; I successfully created the inline comment using position + subject_type instead.
Summary
Problem
Fixes #541
When using Codex type providers, if the
reasoning_effortparameter (e.g.,high) is not supported by the model (e.g.,gpt-5.2-codexonly supportsmedium), the API returns:Without an error rule, this cryptic error is passed directly to users.
Solution
Added a new entry to
DEFAULT_ERROR_RULESinsrc/repository/error-rules.ts:Unsupported value.*is not supported with.*model.*Supported values(regex)thinking_errorChanges
src/repository/error-rules.ts- Added new error rule for Codex reasoning effort mismatchTesting
Created by Claude AI in response to @claude mention
🤖 Generated with Claude Code
Greptile Summary
Added default error rule to handle Codex API errors when
reasoning_effortvalues are incompatible with the model. The rule matches the error pattern "Unsupported value.*is not supported with.*model.*Supported values" and returns a localized Chinese message guiding users to adjust the parameter or switch models. Implementation follows existing patterns with appropriate priority (72) consistent with other thinking-related errors.Confidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant API Gateway participant ErrorDetector participant ErrorRules participant Codex Provider Client->>API Gateway: Request with reasoning_effort='high' API Gateway->>Codex Provider: Forward request (model=gpt-5.2-codex) Codex Provider-->>API Gateway: 400 Error: Unsupported value 'high' API Gateway->>ErrorDetector: Process error response ErrorDetector->>ErrorRules: Match error pattern ErrorRules-->>ErrorDetector: Rule matched (priority 72) ErrorDetector->>ErrorDetector: Apply override response ErrorDetector-->>Client: User-friendly message in Chinese