Skip to content

Commit d6a63fc

Browse files
Merge pull request #71 from OpsLevel/fix-int-filter-args
Indicate that component filter args must always be strings, and fix error handling
2 parents c2fe599 + b505b6f commit d6a63fc

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/cmd/root.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ var rootCmd = &cobra.Command{
261261
"components",
262262
mcp.WithDescription(`Filter and retrieve components in the OpsLevel catalog. Use as specific a filter as possible to narrow down results and avoid fetching a high number of components.
263263
264-
Components represent services, APIs, libraries, and other software artifacts with metadata such as owner (Team), language, framework, maturity level, lifecycle stage, and tier. Lower tier_index indicates greater criticality. Lower level_index indicates lower maturity level (e.g. Bronze=0, Silver=1, Gold=2).
264+
Components represent services, APIs, libraries, and other software artifacts with metadata such as owner (Team), language, framework, maturity level, lifecycle stage, and tier. Lower tier_index indicates greater criticality. Lower level_index indicates lower maturity level (e.g. Bronze="0", Silver="1", Gold="2").
265265
266-
Use the 'filter' parameter to narrow down results.
266+
Use the 'filter' parameter to narrow down results. 'filter' "arg" must always be a string.
267267
For simple filters:
268268
{ "key": "name", "type": "equals", "arg": "service-name" }
269269
@@ -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)