修复claudeResponse流式请求空指针Panic - #2510
Conversation
WalkthroughThe pull request adds nil-safety checks in the "message_delta" path of Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
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. Comment |
…761069f5e528d8ecf786e7008ae 修复claudeResponse流式请求空指针Panic
claude在流式返回某些情况下StopReason为nil,
该错误由于没有recover, 所以会导致panic后整个程序完全退出
如果使用docker守护则表现为docker重启,
需要尽快修复!
panic日志:
new-api-1 | panic: runtime error: invalid memory address or nil pointer dereference
new-api-1 | [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11411f0]
new-api-1 |
new-api-1 | goroutine 1616088 [running]:
new-api-1 | github.com/QuantumNous/new-api/relay/channel/claude.StreamResponseClaude2OpenAI(0x2, 0xc0009020b0)
new-api-1 | /build/relay/channel/claude/relay-claude.go:486 +0x750
new-api-1 | github.com/QuantumNous/new-api/relay/channel/claude.HandleStreamResponseData(0xc00029ab00, 0xc001fd6608, 0xc001d335c0, {0xc0002960d6, 0xc0}, 0x2)
new-api-1 | /build/relay/channel/claude/relay-claude.go:659 +0x26e
new-api-1 | github.com/QuantumNous/new-api/relay/channel/claude.ClaudeStreamHandler.func1({0xc0002960d6?, 0xc001a14080?})
new-api-1 | /build/relay/channel/claude/relay-claude.go:713 +0x3d
new-api-1 | github.com/QuantumNous/new-api/relay/helper.StreamScannerHandler.func4.2()
new-api-1 | /build/relay/helper/stream_scanner.go:228 +0xaa
new-api-1 | created by github.com/QuantumNous/new-api/relay/helper.StreamScannerHandler.func4 in goroutine 1583058
new-api-1 | /build/relay/helper/stream_scanner.go:225 +0x426
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.