Audit all cases where params must not be null, and enforce this using methodInfo via a new methodFlags bitfield that parameterizes method requirements. Write extensive conformance tests catching all the (server-side) crashes that were possible. We should go further and validate schema against the spec, but that is more indirect, more complicated, and potentially slower. For now we adopt this more explicit approach. Still TODO in a subsequent CL: verify the client side of this with client conformance tests. Additionally, improve some error messages that were redundant or leaked internal implementation details. Fixes #195
105 lines
2.2 KiB
Text
105 lines
2.2 KiB
Text
Check robustness to missing fields: servers should reject and otherwise ignore
|
|
bad requests.
|
|
|
|
Fixed bugs:
|
|
- No id in 'initialize' should not panic (#197).
|
|
- No id in 'ping' should not panic (#194).
|
|
- No params in 'initialize' should not panic (#195).
|
|
- Notifications with IDs should not be treated like requests. (#196)
|
|
- No params in 'logging/setLevel' should not panic.
|
|
- No params in 'completion/complete' should not panic.
|
|
- JSON null params should also not panic in these cases.
|
|
|
|
-- prompts --
|
|
code_review
|
|
|
|
-- client --
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"method": "initialize",
|
|
"params": {
|
|
"protocolVersion": "2024-11-05",
|
|
"capabilities": {},
|
|
"clientInfo": { "name": "ExampleClient", "version": "1.0.0" }
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "initialize"
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 2,
|
|
"method": "initialize",
|
|
"params": {
|
|
"protocolVersion": "2024-11-05",
|
|
"capabilities": {},
|
|
"clientInfo": { "name": "ExampleClient", "version": "1.0.0" }
|
|
}
|
|
}
|
|
{"jsonrpc":"2.0", "id": 3, "method": "notifications/initialized"}
|
|
{"jsonrpc":"2.0", "method":"ping"}
|
|
{"jsonrpc":"2.0", "id": 4, "method": "logging/setLevel"}
|
|
{"jsonrpc":"2.0", "id": 5, "method": "completion/complete"}
|
|
{"jsonrpc":"2.0", "id": 4, "method": "logging/setLevel", "params": null}
|
|
|
|
-- server --
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"error": {
|
|
"code": -32600,
|
|
"message": "invalid request: missing required \"params\""
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 2,
|
|
"result": {
|
|
"capabilities": {
|
|
"completions": {},
|
|
"logging": {},
|
|
"prompts": {
|
|
"listChanged": true
|
|
}
|
|
},
|
|
"protocolVersion": "2024-11-05",
|
|
"serverInfo": {
|
|
"name": "testServer",
|
|
"version": "v1.0.0"
|
|
}
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 3,
|
|
"error": {
|
|
"code": -32600,
|
|
"message": "invalid request: unexpected id for \"notifications/initialized\""
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 4,
|
|
"error": {
|
|
"code": -32600,
|
|
"message": "invalid request: missing required \"params\""
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 5,
|
|
"error": {
|
|
"code": -32600,
|
|
"message": "invalid request: missing required \"params\""
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 4,
|
|
"error": {
|
|
"code": -32600,
|
|
"message": "handling 'logging/setLevel': invalid request: missing required \"params\""
|
|
}
|
|
}
|