From 5f2d483952022da71481cfddb9192f014fbce5d3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 21 Mar 2026 20:25:07 +0000 Subject: [PATCH] Add debug logging to CLI and workflow package functions Add meaningful debug logging calls to 5 files that had declared logger variables but minimal or no usage, improving troubleshooting visibility: - pkg/cli/logs_report.go: Log entry for buildToolUsageSummary, buildMissingToolsSummary, buildMissingDataSummary, and buildMCPFailuresSummary with processed run counts - pkg/workflow/tools_parser.go: Log configuration type decisions in parseBashTool, parsePlaywrightTool, and parseSerenaTool - pkg/cli/add_command.go: Log workflow counts and names in addWorkflows, addWorkflowsWithTracking, and addWorkflowWithTracking - pkg/workflow/expression_parser.go: Log BreakAtParentheses entry when actually breaking, and VisitExpressionTree nil-node path - pkg/cli/mcp_inspect_mcp.go: Log connection details in connectToMCPServer, connectStdioMCPServer, and displayServerCapabilities Co-Authored-By: Claude Sonnet 4.6 --- pkg/cli/add_command.go | 4 ++++ pkg/cli/logs_report.go | 4 ++++ pkg/cli/mcp_inspect_mcp.go | 3 +++ pkg/workflow/expression_parser.go | 3 +++ pkg/workflow/tools_parser.go | 7 +++++++ 5 files changed, 21 insertions(+) diff --git a/pkg/cli/add_command.go b/pkg/cli/add_command.go index 6b2020526e3..2d721b34ac8 100644 --- a/pkg/cli/add_command.go +++ b/pkg/cli/add_command.go @@ -228,6 +228,7 @@ func AddResolvedWorkflows(workflowStrings []string, resolved *ResolvedWorkflows, // addWorkflows handles workflow addition using pre-fetched content func addWorkflows(workflows []*ResolvedWorkflow, opts AddOptions) error { + addLog.Printf("Adding %d workflow(s) to repository", len(workflows)) // Create file tracker for all operations tracker, err := NewFileTracker() if err != nil { @@ -242,6 +243,7 @@ func addWorkflows(workflows []*ResolvedWorkflow, opts AddOptions) error { // addWorkflows handles workflow addition using pre-fetched content func addWorkflowsWithTracking(workflows []*ResolvedWorkflow, tracker *FileTracker, opts AddOptions) error { + addLog.Printf("Adding %d workflow(s) with tracking: force=%v, disableSecurityScanner=%v", len(workflows), opts.Force, opts.DisableSecurityScanner) // Ensure .gitattributes is configured unless flag is set if !opts.NoGitattributes { addLog.Print("Configuring .gitattributes") @@ -284,6 +286,8 @@ func addWorkflowWithTracking(resolved *ResolvedWorkflow, tracker *FileTracker, o sourceContent := resolved.Content sourceInfo := resolved.SourceInfo + addLog.Printf("Adding workflow: name=%s, content_size=%d bytes", workflowSpec.WorkflowName, len(sourceContent)) + if opts.Verbose { fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Adding workflow: "+workflowSpec.String())) if opts.Force { diff --git a/pkg/cli/logs_report.go b/pkg/cli/logs_report.go index 93190cf7354..455ee475c54 100644 --- a/pkg/cli/logs_report.go +++ b/pkg/cli/logs_report.go @@ -310,6 +310,7 @@ func isValidToolName(toolName string) bool { // buildToolUsageSummary aggregates tool usage across all runs // Filters out invalid tool names that appear to be fragments or garbage func buildToolUsageSummary(processedRuns []ProcessedRun) []ToolUsageSummary { + reportLog.Printf("Building tool usage summary from %d processed runs", len(processedRuns)) toolStats := make(map[string]*ToolUsageSummary) for _, pr := range processedRuns { @@ -419,6 +420,7 @@ func aggregateSummaryItems[TItem any, TSummary any]( // buildMissingToolsSummary aggregates missing tools across all runs func buildMissingToolsSummary(processedRuns []ProcessedRun) []MissingToolSummary { + reportLog.Printf("Building missing tools summary from %d processed runs", len(processedRuns)) result := aggregateSummaryItems( processedRuns, // getItems: extract missing tools from each run @@ -462,6 +464,7 @@ func buildMissingToolsSummary(processedRuns []ProcessedRun) []MissingToolSummary // buildMissingDataSummary aggregates missing data across all runs func buildMissingDataSummary(processedRuns []ProcessedRun) []MissingDataSummary { + reportLog.Printf("Building missing data summary from %d processed runs", len(processedRuns)) result := aggregateSummaryItems( processedRuns, // getItems: extract missing data from each run @@ -505,6 +508,7 @@ func buildMissingDataSummary(processedRuns []ProcessedRun) []MissingDataSummary // buildMCPFailuresSummary aggregates MCP failures across all runs func buildMCPFailuresSummary(processedRuns []ProcessedRun) []MCPFailureSummary { + reportLog.Printf("Building MCP failures summary from %d processed runs", len(processedRuns)) result := aggregateSummaryItems( processedRuns, // getItems: extract MCP failures from each run diff --git a/pkg/cli/mcp_inspect_mcp.go b/pkg/cli/mcp_inspect_mcp.go index a61fdbe5dc9..6f41f7a80f8 100644 --- a/pkg/cli/mcp_inspect_mcp.go +++ b/pkg/cli/mcp_inspect_mcp.go @@ -111,6 +111,7 @@ func buildConnectionString(config parser.MCPServerConfig) string { // connectToMCPServer establishes a connection to the MCP server and queries its capabilities func connectToMCPServer(config parser.MCPServerConfig, verbose bool) (*parser.MCPServerInfo, error) { + mcpInspectServerLog.Printf("Connecting to MCP server: name=%s, type=%s", config.Name, config.Type) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() @@ -129,6 +130,7 @@ func connectToMCPServer(config parser.MCPServerConfig, verbose bool) (*parser.MC // connectStdioMCPServer connects to a stdio-based MCP server using the Go SDK func connectStdioMCPServer(ctx context.Context, config parser.MCPServerConfig, verbose bool) (*parser.MCPServerInfo, error) { + mcpInspectServerLog.Printf("Connecting to stdio MCP server: command=%s, args=%d", config.Command, len(config.Args)) if verbose { fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Starting stdio MCP server: %s %s", config.Command, strings.Join(config.Args, " ")))) } @@ -340,6 +342,7 @@ func extractRootsFromResources(resources []*mcp.Resource) []*mcp.Root { // displayServerCapabilities shows the server's tools, resources, and roots in formatted tables func displayServerCapabilities(info *parser.MCPServerInfo, toolFilter string) { + mcpInspectServerLog.Printf("Displaying server capabilities: tools=%d, resources=%d, toolFilter=%q", len(info.Tools), len(info.Resources), toolFilter) // Display tools with allowed/not allowed status if len(info.Tools) > 0 { // If a specific tool is requested, show detailed information diff --git a/pkg/workflow/expression_parser.go b/pkg/workflow/expression_parser.go index 5019c85f1b6..d6fed9ca02e 100644 --- a/pkg/workflow/expression_parser.go +++ b/pkg/workflow/expression_parser.go @@ -285,6 +285,7 @@ func (p *ExpressionParser) advance() { // for each ExpressionNode (literal expression) found in the tree func VisitExpressionTree(node ConditionNode, visitor func(expr *ExpressionNode) error) error { if node == nil { + expressionsLog.Print("VisitExpressionTree called with nil node") return nil } @@ -410,6 +411,8 @@ func BreakAtParentheses(expression string) []string { return []string{expression} } + expressionsLog.Printf("Breaking expression at parentheses: length=%d", len(expression)) + var lines []string var current strings.Builder parenDepth := 0 diff --git a/pkg/workflow/tools_parser.go b/pkg/workflow/tools_parser.go index 81305ecaa8b..d9b9cf4803a 100644 --- a/pkg/workflow/tools_parser.go +++ b/pkg/workflow/tools_parser.go @@ -257,6 +257,7 @@ func parseBashTool(val any) *BashToolConfig { if val == nil { // nil is no longer supported - return nil to indicate invalid configuration // The compiler will handle this as a validation error + toolsParserLog.Print("Bash tool configured with nil value (unsupported)") return nil } @@ -264,9 +265,11 @@ func parseBashTool(val any) *BashToolConfig { if boolVal, ok := val.(bool); ok { if boolVal { // bash: true means all commands allowed + toolsParserLog.Print("Bash tool enabled with all commands allowed") return &BashToolConfig{} } // bash: false means explicitly disabled + toolsParserLog.Print("Bash tool explicitly disabled") return &BashToolConfig{ AllowedCommands: []string{}, // Empty slice indicates explicitly disabled } @@ -292,8 +295,10 @@ func parseBashTool(val any) *BashToolConfig { // parsePlaywrightTool converts raw playwright tool configuration to PlaywrightToolConfig func parsePlaywrightTool(val any) *PlaywrightToolConfig { if val == nil { + toolsParserLog.Print("Playwright tool enabled with default configuration") return &PlaywrightToolConfig{} } + toolsParserLog.Print("Parsing playwright tool configuration") if configMap, ok := val.(map[string]any); ok { config := &PlaywrightToolConfig{} @@ -332,11 +337,13 @@ func parsePlaywrightTool(val any) *PlaywrightToolConfig { // parseSerenaTool converts raw serena tool configuration to SerenaToolConfig func parseSerenaTool(val any) *SerenaToolConfig { if val == nil { + toolsParserLog.Print("Serena tool enabled with default configuration") return &SerenaToolConfig{} } // Handle array format (short syntax): ["go", "typescript"] if langArray, ok := val.([]any); ok { + toolsParserLog.Printf("Parsing Serena tool with short-syntax language list: %d languages", len(langArray)) config := &SerenaToolConfig{ ShortSyntax: make([]string, 0, len(langArray)), }