Skip to content

Commit ec8398f

Browse files
committed
Fix handling nil values for optional string array parameters,
nil values should be equivalent to an empty string, currently we return an error but Claude passes nil for optional values.
1 parent 56c1fce commit ec8398f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pkg/github/issues_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ func Test_CreateIssue(t *testing.T) {
471471
"owner": "owner",
472472
"repo": "repo",
473473
"title": "Minimal Issue",
474+
"assignees": nil, // Expect no failure with nil optional value.
474475
},
475476
expectError: false,
476477
expectedIssue: &github.Issue{

pkg/github/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,14 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e
232232
// 1. Checks if the parameter is present in the request, if not, it returns its zero-value
233233
// 2. If it is present, iterates the elements and checks each is a string
234234
func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) {
235-
// Check if the parameter is present in the request
235+
// Check if the parameter is present in the request
236236
if _, ok := r.Params.Arguments[p]; !ok {
237237
return []string{}, nil
238238
}
239239

240-
switch v := r.Params.Arguments[p].(type) {
240+
switch v := r.Params.Arguments[p].(type) {
241+
case nil:
242+
return []string{}, nil
241243
case []string:
242244
return v, nil
243245
case []any:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy