Fix #518: Add error rule for Invalid signature in thinking block#519
Fix #518: Add error rule for Invalid signature in thinking block#519
Conversation
Fixes #518 Added new error rule to handle "Invalid \`signature\` in \`thinking\` block" error that commonly occurs when switching between Anthropic and non-Anthropic channels. Changes: - Added new error rule with pattern matching for signature validation error - Category: thinking_error - Match type: contains (for exact string matching) - Priority: 71 (higher than generic thinking error rule at 70) - Chinese error message for better user experience 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 Walkthrough概述在 变更
预估代码审查工作量🎯 1 (Trivial) | ⏱️ ~3 分钟 Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ 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 the system's error handling capabilities by adding a dedicated rule for the 'Invalid 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 adds a new error rule to handle the 'Invalid signature in thinking block' error, which improves error handling clarity for users switching between different channel types. The change is straightforward and well-implemented.
My review includes one main point regarding the priority setting for the new rule. There appears to be an inconsistency between the intended priority logic (higher number = higher priority) and the actual implementation in the database query (ascending sort). While your change works correctly in this specific instance due to differing matchTypes, I've suggested an adjustment to make the priority handling more robust and align with the existing code's behavior.
Overall, a good addition to improve user experience.
🧪 测试结果
总体结果: ✅ 所有测试通过 |
There was a problem hiding this comment.
Code Review Summary
No significant issues identified in this PR.
PR Size: XS
- Lines changed: 19
- Files changed: 1
Review Coverage
- Logic and correctness - Clean
- Security (OWASP Top 10) - Clean
- Error handling - Clean
- Type safety - Clean
- Documentation accuracy - Clean
- Test coverage - Adequate
- Code clarity - Good
Automated review by Codex AI
There was a problem hiding this comment.
- Identified PR
#519and applied the labelsize/XS(19 lines changed, 1 file). - Reviewed the diff (only
src/repository/error-rules.ts#L625changes) across logic/security/error-handling/types/docs/tests/simplification. - No issues in the changed lines met the reporting threshold (>=80 confidence), so no inline comments were posted; a summary review was submitted via
gh pr review.
Summary
Added a new error rule to handle "Invalid `signature` in `thinking` block" error that commonly occurs when switching between Anthropic and non-Anthropic channels.
Problem
Fixes #518
The error "Invalid `signature` in `thinking` block" was not matched by existing error rules, causing unclear error messages for users. This error commonly occurs when requests alternate between Anthropic channels and non-Anthropic channels.
Solution
Added a new error rule in
src/repository/error-rules.ts:Invalid \signature` in `thinking` block`contains(for precise matching)thinking_errorChanges
DEFAULT_ERROR_RULESarray in/src/repository/error-rules.ts:625-643signatureinthinkingblock #518Testing
Notes
This rule will be automatically synced to the database when the application starts or when users refresh the error rules cache.
Created by Claude AI in response to @claude mention
Greptile Summary
Added a new error rule to handle "Invalid
signatureinthinkingblock" errors that occur when switching between Anthropic and non-Anthropic channels. The implementation correctly:matchType: "contains"for precise string matchingcategory: "thinking_error"to group with related errorssignatureinthinkingblock #518The rule will be automatically synced to the database on application startup via
syncDefaultErrorRules(). The pattern is specific enough that it won't conflict with the generic thinking error rule at priority 70.Confidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant ProxyServer participant ErrorDetector participant Database participant AnthropicAPI as Anthropic/Non-Anthropic API Note over ProxyServer: Application Startup ProxyServer->>Database: syncDefaultErrorRules() Database-->>ProxyServer: New rule inserted/updated ProxyServer->>ErrorDetector: reload() triggered ErrorDetector->>Database: getActiveErrorRules() Database-->>ErrorDetector: All enabled rules (sorted by priority) ErrorDetector->>ErrorDetector: Parse rules into containsPatterns Note over ErrorDetector: New rule added to cache at priority 71 Note over Client: Runtime Error Occurs Client->>ProxyServer: API Request ProxyServer->>AnthropicAPI: Forward request AnthropicAPI-->>ProxyServer: Error: Invalid `signature` in `thinking` block ProxyServer->>ErrorDetector: detectAsync(errorMessage) ErrorDetector->>ErrorDetector: Iterate through containsPatterns (priority order) ErrorDetector->>ErrorDetector: Check generic thinking rule (priority 70) - no match ErrorDetector->>ErrorDetector: Check signature thinking rule (priority 71) - MATCH! ErrorDetector-->>ProxyServer: Return overrideResponse ProxyServer->>ProxyServer: Replace error message with Chinese translation ProxyServer-->>Client: Friendly error: "thinking 块签名无效..."