Skip to content

Commit b505b6f

Browse files
Surface filter parsing errors properly
1 parent 79188af commit b505b6f

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/cmd/root.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,17 @@ For complete reference:
302302
if filterObj, exists := args["filter"]; exists && filterObj != nil {
303303
// Marshal then unmarshal to our struct for type safety
304304
filterBytes, marshalErr := json.Marshal(filterObj)
305-
if marshalErr == nil {
306-
var f componentFilter
307-
if unmarshalErr := json.Unmarshal(filterBytes, &f); unmarshalErr == nil {
308-
filterInput = &f
309-
}
305+
if marshalErr != nil {
306+
return mcp.NewToolResultErrorFromErr("failed to marshal filter argument", marshalErr), nil
310307
}
308+
var f componentFilter
309+
if unmarshalErr := json.Unmarshal(filterBytes, &f); unmarshalErr != nil {
310+
return mcp.NewToolResultErrorFromErr("failed to unmarshal filter argument", unmarshalErr), nil
311+
}
312+
filterInput = &f
311313
}
312314

313315
if filterInput != nil {
314-
// Convert to ServiceFilterInput for the API
315316
serviceFilter, convertErr := convertToServiceFilterInput(*filterInput)
316317
if convertErr != nil {
317318
return mcp.NewToolResultErrorFromErr("failed to convert filter", convertErr), nil

0 commit comments

Comments
 (0)