From ec8398f47bf33c2117fc429de26b7a7b58d90f4b Mon Sep 17 00:00:00 2001 From: Andrew Georgiou Date: Wed, 9 Apr 2025 13:20:10 +0000 Subject: [PATCH 1/2] 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. --- pkg/github/issues_test.go | 1 + pkg/github/server.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 04a2ae193..7e48a443a 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -471,6 +471,7 @@ func Test_CreateIssue(t *testing.T) { "owner": "owner", "repo": "repo", "title": "Minimal Issue", + "assignees": nil, // Expect no failure with nil optional value. }, expectError: false, expectedIssue: &github.Issue{ diff --git a/pkg/github/server.go b/pkg/github/server.go index 84c15f509..9b77a5e28 100644 --- a/pkg/github/server.go +++ b/pkg/github/server.go @@ -232,12 +232,14 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e // 1. Checks if the parameter is present in the request, if not, it returns its zero-value // 2. If it is present, iterates the elements and checks each is a string func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) { - // Check if the parameter is present in the request + // Check if the parameter is present in the request if _, ok := r.Params.Arguments[p]; !ok { return []string{}, nil } - switch v := r.Params.Arguments[p].(type) { + switch v := r.Params.Arguments[p].(type) { + case nil: + return []string{}, nil case []string: return v, nil case []any: From d8b2273e5bbca08e33c3441440de4adc9ceb371f Mon Sep 17 00:00:00 2001 From: Andrew Georgiou Date: Wed, 9 Apr 2025 13:24:23 +0000 Subject: [PATCH 2/2] lint fixes --- pkg/github/issues_test.go | 8 ++++---- pkg/github/server.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 7e48a443a..e8b16e024 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -468,10 +468,10 @@ func Test_CreateIssue(t *testing.T) { ), ), requestArgs: map[string]interface{}{ - "owner": "owner", - "repo": "repo", - "title": "Minimal Issue", - "assignees": nil, // Expect no failure with nil optional value. + "owner": "owner", + "repo": "repo", + "title": "Minimal Issue", + "assignees": nil, // Expect no failure with nil optional value. }, expectError: false, expectedIssue: &github.Issue{ diff --git a/pkg/github/server.go b/pkg/github/server.go index 9b77a5e28..80457a54f 100644 --- a/pkg/github/server.go +++ b/pkg/github/server.go @@ -232,12 +232,12 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e // 1. Checks if the parameter is present in the request, if not, it returns its zero-value // 2. If it is present, iterates the elements and checks each is a string func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) { - // Check if the parameter is present in the request + // Check if the parameter is present in the request if _, ok := r.Params.Arguments[p]; !ok { return []string{}, nil } - switch v := r.Params.Arguments[p].(type) { + switch v := r.Params.Arguments[p].(type) { case nil: return []string{}, nil case []string: 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