From bfdbcecf489ad2e034d32914555bd10b4444cf47 Mon Sep 17 00:00:00 2001 From: GitHub Agent Date: Wed, 4 Mar 2026 20:29:00 +0000 Subject: [PATCH 1/2] Add debug logging to tar extraction, schema utilities, MCP config, and wizard command - pkg/fileutil/tar.go: Log target path, archive size, entries scanned, and whether file was found - pkg/parser/schema_utilities.go: Log ignored field filtering with counts and field names - pkg/cli/mcp_schema.go: Log schema property default assignments and missing properties - pkg/workflow/mcp_config_types.go: Log well-known container lookups for MCP commands - pkg/cli/add_wizard_command.go: Log wizard startup parameters and TTY/CI detection results Co-Authored-By: Claude Sonnet 4.6 --- pkg/cli/add_wizard_command.go | 10 +++++++++- pkg/cli/mcp_schema.go | 5 +++++ pkg/fileutil/tar.go | 9 +++++++++ pkg/parser/schema_utilities.go | 9 ++++++++- pkg/workflow/mcp_config_types.go | 11 ++++++++++- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/pkg/cli/add_wizard_command.go b/pkg/cli/add_wizard_command.go index 443c116dba9..219b965239d 100644 --- a/pkg/cli/add_wizard_command.go +++ b/pkg/cli/add_wizard_command.go @@ -5,10 +5,13 @@ import ( "os" "github.com/github/gh-aw/pkg/constants" + "github.com/github/gh-aw/pkg/logger" "github.com/github/gh-aw/pkg/tty" "github.com/spf13/cobra" ) +var addWizardLog = logger.New("cli:add_wizard_command") + // NewAddWizardCommand creates the add-wizard command, which is always interactive. func NewAddWizardCommand(validateEngine func(string) error) *cobra.Command { cmd := &cobra.Command{ @@ -54,12 +57,17 @@ Note: To create a new workflow from scratch, use the 'new' command instead.`, noStopAfter, _ := cmd.Flags().GetBool("no-stop-after") stopAfter, _ := cmd.Flags().GetString("stop-after") + addWizardLog.Printf("Starting add-wizard: workflows=%v, engine=%s, verbose=%v", workflows, engineOverride, verbose) + if err := validateEngine(engineOverride); err != nil { return err } // add-wizard requires an interactive terminal - if !tty.IsStdoutTerminal() || os.Getenv("CI") != "" { + isTerminal := tty.IsStdoutTerminal() + isCIEnv := os.Getenv("CI") != "" + addWizardLog.Printf("Terminal check: is_terminal=%v, is_ci=%v", isTerminal, isCIEnv) + if !isTerminal || isCIEnv { return errors.New("add-wizard requires an interactive terminal; use 'add' for non-interactive environments") } diff --git a/pkg/cli/mcp_schema.go b/pkg/cli/mcp_schema.go index 5def4b2de9e..0e59dfd5294 100644 --- a/pkg/cli/mcp_schema.go +++ b/pkg/cli/mcp_schema.go @@ -4,9 +4,12 @@ import ( "encoding/json" "fmt" + "github.com/github/gh-aw/pkg/logger" "github.com/google/jsonschema-go/jsonschema" ) +var mcpSchemaLog = logger.New("cli:mcp_schema") + // GenerateSchema generates a JSON schema from a Go struct type. // This is used for both MCP tool input parameters (InputSchema) and output data types. // The schema conforms to JSON Schema draft 2020-12 and draft-07. @@ -54,6 +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 } @@ -63,6 +67,7 @@ func AddSchemaDefault(schema *jsonschema.Schema, propertyName string, value any) return fmt.Errorf("failed to marshal default value for %s: %w", propertyName, err) } + mcpSchemaLog.Printf("Setting default value for schema property: %s", propertyName) prop.Default = json.RawMessage(defaultBytes) return nil } diff --git a/pkg/fileutil/tar.go b/pkg/fileutil/tar.go index 97cfec784f2..601aa064722 100644 --- a/pkg/fileutil/tar.go +++ b/pkg/fileutil/tar.go @@ -5,22 +5,31 @@ import ( "bytes" "fmt" "io" + + "github.com/github/gh-aw/pkg/logger" ) +var tarLog = logger.New("fileutil:tar") + // ExtractFileFromTar extracts a single file from a tar archive. // Uses Go's standard archive/tar for cross-platform compatibility instead of // spawning an external tar process which may not be available on all platforms. func ExtractFileFromTar(data []byte, path string) ([]byte, error) { + tarLog.Printf("Extracting file from tar archive: target=%s, archive_size=%d bytes", path, len(data)) tr := tar.NewReader(bytes.NewReader(data)) + entriesScanned := 0 for { header, err := tr.Next() if err == io.EOF { + tarLog.Printf("File not found in tar archive after scanning %d entries: %s", entriesScanned, path) break } if err != nil { return nil, fmt.Errorf("failed to read tar archive: %w", err) } + entriesScanned++ if header.Name == path { + tarLog.Printf("Found file in tar archive after scanning %d entries: %s", entriesScanned, path) return io.ReadAll(tr) } } diff --git a/pkg/parser/schema_utilities.go b/pkg/parser/schema_utilities.go index 1c628f1a973..18dda1cf608 100644 --- a/pkg/parser/schema_utilities.go +++ b/pkg/parser/schema_utilities.go @@ -4,8 +4,11 @@ import ( "slices" "github.com/github/gh-aw/pkg/constants" + "github.com/github/gh-aw/pkg/logger" ) +var schemaUtilitiesLog = logger.New("parser:schema_utilities") + // filterIgnoredFields removes ignored fields from frontmatter without warnings // NOTE: This function is kept for backward compatibility but currently does nothing // as all previously ignored fields (description, applyTo) are now validated by the schema @@ -20,12 +23,16 @@ func filterIgnoredFields(frontmatter map[string]any) map[string]any { return frontmatter } + schemaUtilitiesLog.Printf("Filtering ignored frontmatter fields: checking %d ignored field(s) against %d frontmatter keys", len(constants.IgnoredFrontmatterFields), len(frontmatter)) + // Create a copy of the frontmatter map without ignored fields filtered := make(map[string]any) for key, value := range frontmatter { // Skip ignored fields ignored := slices.Contains(constants.IgnoredFrontmatterFields, key) - if !ignored { + if ignored { + schemaUtilitiesLog.Printf("Removing ignored frontmatter field: %s", key) + } else { filtered[key] = value } } diff --git a/pkg/workflow/mcp_config_types.go b/pkg/workflow/mcp_config_types.go index 7405740d4f3..916eb6c3619 100644 --- a/pkg/workflow/mcp_config_types.go +++ b/pkg/workflow/mcp_config_types.go @@ -2,8 +2,11 @@ package workflow import ( "github.com/github/gh-aw/pkg/constants" + "github.com/github/gh-aw/pkg/logger" ) +var mcpConfigTypesLog = logger.New("workflow:mcp_config_types") + // WellKnownContainer represents a container configuration for a well-known command type WellKnownContainer struct { Image string // Container image (e.g., "node:lts-alpine") @@ -24,7 +27,13 @@ func getWellKnownContainer(command string) *WellKnownContainer { }, } - return wellKnownContainers[command] + container := wellKnownContainers[command] + if container != nil { + mcpConfigTypesLog.Printf("Found well-known container for command: command=%s, image=%s", command, container.Image) + } else { + mcpConfigTypesLog.Printf("No well-known container found for command: %s", command) + } + return container } // MCPConfigRenderer contains configuration options for rendering MCP config From d8e8c0120cc4d3574f4d6511ad33adaec431d828 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 4 Mar 2026 20:31:26 +0000 Subject: [PATCH 2/2] ci: trigger checks