Conversation
…andling [#318] Three independent fixes for the crash chain reported in #318: 1. Named return values in panic recovery (handleCallToolVariant, handleCallTool): recover() now sets callResult via named returns instead of returning (nil, nil), preventing the second unrecovered panic in mcp-go's HandleMessage. 2. Safe tokenizer access (SafeGetDefaultEncoding): Replaces unsafe type assertion `tokenizer.(*DefaultTokenizer).GetDefaultEncoding()` with a nil-safe helper that handles nil interface, nil underlying value, and non-DefaultTokenizer implementations. 3. Skip tiktoken validation for disabled tokenizer (NewTokenizer): When enabled=false, encoding validation is skipped so the fallback path always succeeds even with a corrupted tiktoken cache. 4. Guard against nil serverConfig in GenerateServerID calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
7e9c698
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fee3adb4.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-panic-recovery-nil-token.mcpproxy-docs.pages.dev |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 22814426068 --repo smart-mcp-proxy/mcpproxy-go
|
…#318] Rewrite panic recovery tests to trigger real panics by nil-ing out proxy.storage, causing nil pointer dereference inside the handler. This verifies the named-return-value recover block actually catches panics and returns a proper error result (not nil, nil). Three subtests: - normal error path (server not found) returns error result - panic in handleCallToolVariant returns error result via recover - panic in legacy handleCallTool returns error result via recover Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #318 —
handleCallToolVariantpanic recovery returned(nil, nil), causing a second unrecovered panic in mcp-go and dropping the HTTP connection.recover()now setscallResultvia named returns, returning a proper error tool result instead of(nil, nil). Applied to bothhandleCallToolVariantand legacyhandleCallTool.tokenizer.(*DefaultTokenizer).GetDefaultEncoding()withSafeGetDefaultEncoding()— handles nil interface, nil underlying value, and non-DefaultTokenizer types.NewTokenizer(encoding, logger, false)no longer callstiktoken.GetEncoding(), so the fallback always succeeds even with a corrupted cache.GenerateServerID(serverConfig)is now guarded against nil (when storage lookup fails).Test plan
TestNewTokenizerDisabledWithInvalidEncoding— disabled tokenizer created with corrupted encodingTestNilTokenizerInterfaceSafety— nil concrete in interface doesn't panicTestSafeGetDefaultEncoding— all nil/valid/interface scenariosTestHandleCallToolVariant_PanicRecovery— never returns(nil, nil)./scripts/test-api-e2e.sh)🤖 Generated with Claude Code