Skip to content

Commit 6bc6027

Browse files
committed
Fix sos-search-commands tools issue
when output is empty, the Matches slice in SearchCommandsResult was nil. When marshaled and returned via MCP, this resulted in "matches": null in the JSON output, causing schema validation failures. This fix ensures that even when no commands are found, the JSON output always contains "matches": [] and conforms to the MCP tool schema. Signed-off-by: Meina-rh <meinli@redhat.com>
1 parent 54df8bd commit 6bc6027

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/sosreport/mcp/commands.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"path/filepath"
77
"regexp"
8+
89
"github.com/ovn-kubernetes/ovn-kubernetes-mcp/pkg/sosreport/types"
910
)
1011

@@ -122,7 +123,9 @@ func searchCommands(sosreportPath, pattern string, maxResults int) (types.Search
122123
return types.SearchCommandsResult{}, fmt.Errorf("invalid search pattern: %w", err)
123124
}
124125

125-
var result types.SearchCommandsResult
126+
result := types.SearchCommandsResult{
127+
Matches: []types.CommandMatch{},
128+
}
126129
if maxResults <= 0 {
127130
maxResults = defaultResultLimit
128131
}

0 commit comments

Comments
 (0)