-
Notifications
You must be signed in to change notification settings - Fork 487
fix: type mismatch for request/response ID #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rwjblue-glean
merged 4 commits into
mark3labs:main
from
pottekkat:fix/type-mismatch/154
May 16, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,7 @@ func TestSSE(t *testing.T) { | |
|
||
request := JSONRPCRequest{ | ||
JSONRPC: "2.0", | ||
ID: 1, | ||
ID: mcp.NewRequestId(int64(1)), | ||
Method: "debug/echo", | ||
Params: params, | ||
} | ||
|
@@ -174,7 +174,7 @@ func TestSSE(t *testing.T) { | |
// Parse the result to verify echo | ||
var result struct { | ||
JSONRPC string `json:"jsonrpc"` | ||
ID int64 `json:"id"` | ||
ID mcp.RequestId `json:"id"` | ||
Method string `json:"method"` | ||
Params map[string]any `json:"params"` | ||
} | ||
|
@@ -187,8 +187,11 @@ func TestSSE(t *testing.T) { | |
if result.JSONRPC != "2.0" { | ||
t.Errorf("Expected JSONRPC value '2.0', got '%s'", result.JSONRPC) | ||
} | ||
if result.ID != 1 { | ||
t.Errorf("Expected ID 1, got %d", result.ID) | ||
idValue, ok := result.ID.Value().(int64) | ||
if !ok { | ||
t.Errorf("Expected ID to be int64, got %T", result.ID.Value()) | ||
Comment on lines
+190
to
+192
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also check the type. |
||
} else if idValue != 1 { | ||
t.Errorf("Expected ID 1, got %d", idValue) | ||
} | ||
if result.Method != "debug/echo" { | ||
t.Errorf("Expected method 'debug/echo', got '%s'", result.Method) | ||
|
@@ -211,7 +214,7 @@ func TestSSE(t *testing.T) { | |
// Prepare a request | ||
request := JSONRPCRequest{ | ||
JSONRPC: "2.0", | ||
ID: 3, | ||
ID: mcp.NewRequestId(int64(3)), | ||
Method: "debug/echo", | ||
} | ||
|
||
|
@@ -292,7 +295,7 @@ func TestSSE(t *testing.T) { | |
// Each request has a unique ID and payload | ||
request := JSONRPCRequest{ | ||
JSONRPC: "2.0", | ||
ID: int64(100 + idx), | ||
ID: mcp.NewRequestId(int64(100 + idx)), | ||
Method: "debug/echo", | ||
Params: map[string]any{ | ||
"requestIndex": idx, | ||
|
@@ -317,15 +320,25 @@ func TestSSE(t *testing.T) { | |
continue | ||
} | ||
|
||
if responses[i] == nil || responses[i].ID == nil || *responses[i].ID != int64(100+i) { | ||
t.Errorf("Request %d: Expected ID %d, got %v", i, 100+i, responses[i]) | ||
if responses[i] == nil { | ||
t.Errorf("Request %d: Response is nil", i) | ||
continue | ||
} | ||
|
||
expectedId := int64(100 + i) | ||
idValue, ok := responses[i].ID.Value().(int64) | ||
if !ok { | ||
t.Errorf("Request %d: Expected ID to be int64, got %T", i, responses[i].ID.Value()) | ||
continue | ||
} else if idValue != expectedId { | ||
t.Errorf("Request %d: Expected ID %d, got %d", i, expectedId, idValue) | ||
continue | ||
} | ||
|
||
// Parse the result to verify echo | ||
var result struct { | ||
JSONRPC string `json:"jsonrpc"` | ||
ID int64 `json:"id"` | ||
ID mcp.RequestId `json:"id"` | ||
Method string `json:"method"` | ||
Params map[string]any `json:"params"` | ||
} | ||
|
@@ -336,8 +349,11 @@ func TestSSE(t *testing.T) { | |
} | ||
|
||
// Verify data matches what was sent | ||
if result.ID != int64(100+i) { | ||
t.Errorf("Request %d: Expected echoed ID %d, got %d", i, 100+i, result.ID) | ||
idValue, ok = result.ID.Value().(int64) | ||
if !ok { | ||
t.Errorf("Request %d: Expected ID to be int64, got %T", i, result.ID.Value()) | ||
} else if idValue != int64(100+i) { | ||
t.Errorf("Request %d: Expected echoed ID %d, got %d", i, 100+i, idValue) | ||
} | ||
|
||
if result.Method != "debug/echo" { | ||
|
@@ -356,7 +372,7 @@ func TestSSE(t *testing.T) { | |
// Prepare a request | ||
request := JSONRPCRequest{ | ||
JSONRPC: "2.0", | ||
ID: 100, | ||
ID: mcp.NewRequestId(int64(100)), | ||
Method: "debug/echo_error_string", | ||
} | ||
|
||
|
@@ -378,8 +394,11 @@ func TestSSE(t *testing.T) { | |
if responseError.Method != "debug/echo_error_string" { | ||
t.Errorf("Expected method 'debug/echo_error_string', got '%s'", responseError.Method) | ||
} | ||
if responseError.ID != 100 { | ||
t.Errorf("Expected ID 100, got %d", responseError.ID) | ||
idValue, ok := responseError.ID.Value().(int64) | ||
if !ok { | ||
t.Errorf("Expected ID to be int64, got %T", responseError.ID.Value()) | ||
} else if idValue != 100 { | ||
t.Errorf("Expected ID 100, got %d", idValue) | ||
} | ||
if responseError.JSONRPC != "2.0" { | ||
t.Errorf("Expected JSONRPC '2.0', got '%s'", responseError.JSONRPC) | ||
|
@@ -453,7 +472,7 @@ func TestSSEErrors(t *testing.T) { | |
// Prepare a request | ||
request := JSONRPCRequest{ | ||
JSONRPC: "2.0", | ||
ID: 99, | ||
ID: mcp.NewRequestId(int64(99)), | ||
Method: "ping", | ||
} | ||
|
||
|
@@ -492,7 +511,7 @@ func TestSSEErrors(t *testing.T) { | |
// Try to send a request after close | ||
request := JSONRPCRequest{ | ||
JSONRPC: "2.0", | ||
ID: 1, | ||
ID: mcp.NewRequestId(int64(1)), | ||
Method: "ping", | ||
} | ||
|
||
|
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use string version of the id for lookups to ensure consistency.