Skip to content

fix: 移除不必要的 unescapeMapOrSlice 调用,修复 Windows 路径转义问题 - #2814

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
thirking:fix/remove-unescape-function
Feb 3, 2026
Merged

Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
thirking:fix/remove-unescape-function

Conversation

@thirking

@thirking thirking commented Feb 3, 2026 •

Copy link
Copy Markdown

问题描述

修复 Windows 路径中包含转义字符(如 "\t", "\n", "\b", "\f" 等)时被错误转义的问题。

当使用 Gemini 模型时,如果用户发送的消息包含 Windows 路径如

路径中的 "\t" 会被错误地转换为制表符,导致 AI 处理错误。

修复内容

  • 移除了 "getResponseToolCall" 函数中对 "unescapeMapOrSlice" 的不必要调用
  • JSON 序列化/反序列化已经正确处理了转义字符,无需额外处理

测试验证

已本地测试验证:路径中的转义字符现在能正确保持为字面量,不会被错误转义。

关联 Issue

fixes #1620

The JSON serialization/deserialization already handles escape characters
correctly, so the unescapeMapOrSlice function is redundant.
@coderabbitai

coderabbitai Bot commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

This change removes special unescaping logic from the Gemini relay's function argument marshalling, simplifying it to directly serialize arguments via json.Marshal() while relying on prior processing to handle proper escape character handling.

Changes

Cohort / File(s) Summary
Gemini Relay Function Marshalling
relay/channel/gemini/relay-gemini.go
Simplified function argument serialization by removing conditional branch that specially unescaped map[string]interface{} results; now directly marshals arguments as-is, delegating escape handling to upstream processing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A backslash walked into a relay,
Too many escapes led it astray!
We trimmed the logic, kept it pure,
Now arguments flow with less cure. ✨
—Hoppy the code-fixing rabbit 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing unnecessary unescapeMapOrSlice calls to fix Windows path escaping issues.
Linked Issues check ✅ Passed The PR directly addresses the requirements in issue #1620 by removing the unescapeMapOrSlice function call that was causing Windows path escape sequences to be incorrectly processed.
Out of Scope Changes check ✅ Passed The changes are limited to the relay-gemini.go file and focus solely on removing the problematic unescapeMapOrSlice call, directly aligned with the stated objectives.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit 5889856 into QuantumNous:main Feb 3, 2026
@thirking
thirking deleted the fix/remove-unescape-function branch February 3, 2026 09:54
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…-function

fix: 移除不必要的 unescapeMapOrSlice 调用,修复 Windows 路径转义问题
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
…-function

fix: 移除不必要的 unescapeMapOrSlice 调用,修复 Windows 路径转义问题
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
…-function

fix: 移除不必要的 unescapeMapOrSlice 调用,修复 Windows 路径转义问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

转义符转义问题

2 participants