From a1c7b3c2e35868e0a0e0271efa98cbf4099c7382 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 13:51:22 +0000 Subject: [PATCH 1/3] Initial plan From 6cb7d0db2907a8d8bbf2f3cb1168b3f2b3c66455 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 14:00:59 +0000 Subject: [PATCH 2/3] Tighten MCP schema default validation Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com> --- pkg/cli/mcp_argument_validation_test.go | 21 +++++++++++++++++++++ pkg/cli/mcp_schema.go | 3 +-- pkg/cli/mcp_schema_test.go | 11 +++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pkg/cli/mcp_argument_validation_test.go b/pkg/cli/mcp_argument_validation_test.go index ff213c22dae..c4543141532 100644 --- a/pkg/cli/mcp_argument_validation_test.go +++ b/pkg/cli/mcp_argument_validation_test.go @@ -6,6 +6,7 @@ import ( "context" "testing" + "github.com/google/jsonschema-go/jsonschema" "github.com/modelcontextprotocol/go-sdk/jsonrpc" "github.com/modelcontextprotocol/go-sdk/mcp" "github.com/stretchr/testify/assert" @@ -72,6 +73,26 @@ func TestExtractUnknownParams(t *testing.T) { } } +func TestExtractUnknownParamsWithLiveJSONSchemaError(t *testing.T) { + type sampleArgs struct { + Name string `json:"name" jsonschema:"Name field"` + } + + schema, err := GenerateSchema[sampleArgs]() + require.NoError(t, err) + + resolved, err := schema.Resolve(&jsonschema.ResolveOptions{}) + require.NoError(t, err) + + err = resolved.Validate(map[string]any{ + "name": "octocat", + "workflow-name": "typo", + }) + require.Error(t, err) + assert.Contains(t, err.Error(), "unexpected additional properties") + assert.Equal(t, []string{"workflow-name"}, extractUnknownParams(err.Error())) +} + // TestFindSimilarParam verifies the fuzzy matching of parameter names. func TestFindSimilarParam(t *testing.T) { compileParams := []string{"actionlint", "fix", "max_tokens", "poutine", "runner-guard", "strict", "workflows", "zizmor"} diff --git a/pkg/cli/mcp_schema.go b/pkg/cli/mcp_schema.go index 0e59dfd5294..6ffaca3c832 100644 --- a/pkg/cli/mcp_schema.go +++ b/pkg/cli/mcp_schema.go @@ -57,8 +57,7 @@ func AddSchemaDefault(schema *jsonschema.Schema, propertyName string, value any) prop, ok := schema.Properties[propertyName] if !ok { - mcpSchemaLog.Printf("Schema property not found, skipping default: %s", propertyName) - return nil // Property doesn't exist, nothing to do + return fmt.Errorf("schema property %q not found", propertyName) } // Marshal the value to JSON diff --git a/pkg/cli/mcp_schema_test.go b/pkg/cli/mcp_schema_test.go index 14011f73d91..da95d855ce5 100644 --- a/pkg/cli/mcp_schema_test.go +++ b/pkg/cli/mcp_schema_test.go @@ -258,7 +258,7 @@ func TestAddSchemaDefault(t *testing.T) { } }) - t.Run("handles non-existent property gracefully", func(t *testing.T) { + t.Run("returns an error for non-existent property", func(t *testing.T) { type TestStruct struct { Name string `json:"name" jsonschema:"Name field"` } @@ -268,9 +268,12 @@ func TestAddSchemaDefault(t *testing.T) { t.Fatalf("GenerateSchema failed: %v", err) } - // Try to add default to non-existent property - should not error - if err := AddSchemaDefault(schema, "nonexistent", "value"); err != nil { - t.Errorf("AddSchemaDefault should not error on non-existent property: %v", err) + err = AddSchemaDefault(schema, "nonexistent", "value") + if err == nil { + t.Fatal("AddSchemaDefault should error on non-existent property") + } + if err.Error() != `schema property "nonexistent" not found` { + t.Fatalf("unexpected error: %v", err) } }) From 3b95729ed703363271b9f245117d72454e920548 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 14:02:16 +0000 Subject: [PATCH 3/3] Polish MCP schema regression test name Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com> --- pkg/cli/mcp_argument_validation_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cli/mcp_argument_validation_test.go b/pkg/cli/mcp_argument_validation_test.go index c4543141532..dd10da4c6aa 100644 --- a/pkg/cli/mcp_argument_validation_test.go +++ b/pkg/cli/mcp_argument_validation_test.go @@ -73,7 +73,7 @@ func TestExtractUnknownParams(t *testing.T) { } } -func TestExtractUnknownParamsWithLiveJSONSchemaError(t *testing.T) { +func TestExtractUnknownParamsFromSchemaError(t *testing.T) { type sampleArgs struct { Name string `json:"name" jsonschema:"Name field"` }