Skip to content

Commit bb596cd

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 1b4123e commit bb596cd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.github/workflows/e2e.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
include:
2525
- {mode: "live-cluster"}
2626
- {mode: "offline"}
27-
env:
28-
JOB_NAME: "${{ matrix.mode }}"
2927
steps:
3028
- name: Check out code into the Go module directory
3129
uses: actions/checkout@v4
@@ -89,7 +87,7 @@ jobs:
8987
if: always() && matrix.mode == 'live-cluster'
9088
uses: actions/upload-artifact@v4
9189
with:
92-
name: kind-logs-e2e-${{ github.run_id }}
90+
name: kind-logs-e2e-${{ matrix.mode }}-${{ github.run_id }}
9391
path: /tmp/kind/logs
9492
if-no-files-found: ignore
9593

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)