Nil pointer dereference in logReceiveError closes #4798 (#4842)

* Unskip test demonstrating bug #4798: Nil pointer dereference in logReceiveError

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4798: Add nil check to logReceiveError

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Nathan Wallace
2025-11-15 23:50:17 +08:00
committed by GitHub
parent e278975448
commit 6016a71053
2 changed files with 16 additions and 0 deletions

View File

@@ -71,6 +71,9 @@ func (m *PluginMessageServer) runMessageListener(stream sdkproto.WrapperPlugin_E
}
func (m *PluginMessageServer) logReceiveError(err error, connection string) {
if err == nil {
return
}
log.Printf("[TRACE] receive error for connection '%s': %v", connection, err)
switch {
case sdkgrpc.IsEOFError(err):

View File

@@ -72,6 +72,19 @@ func TestPluginMessageServer_LogReceiveError(t *testing.T) {
ms.logReceiveError(context.DeadlineExceeded, "test-connection")
}
// TestPluginMessageServer_LogReceiveError_NilError tests that logReceiveError
// handles nil error gracefully without panicking
func TestPluginMessageServer_LogReceiveError_NilError(t *testing.T) {
// Create a message server
pm := &PluginManager{}
server := &PluginMessageServer{
pluginManager: pm,
}
// This should not panic - calling logReceiveError with nil error
server.logReceiveError(nil, "test-connection")
}
// Test 5: Multiple Message Servers
func TestPluginManager_MultipleMessageServers(t *testing.T) {