Skip to content

Commit a8a464c

Browse files
[log] Add debug logging to 5 pkg/ files (#19455)
1 parent cc464de commit a8a464c

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

pkg/cli/generate_action_metadata_command.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ func GenerateActionMetadataCommand() error {
5959
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("🔍 Generating actions for %d JavaScript modules...", len(targetFiles))))
6060

6161
generatedCount := 0
62+
generateActionMetadataLog.Printf("Processing %d target JavaScript files in %s", len(targetFiles), jsDir)
6263
for _, filename := range targetFiles {
6364
jsPath := filepath.Join(jsDir, filename)
65+
generateActionMetadataLog.Printf("Processing file: %s", filename)
6466

6567
// Read file content directly from filesystem
6668
contentBytes, err := os.ReadFile(jsPath)
6769
if err != nil {
70+
generateActionMetadataLog.Printf("Skipping %s: failed to read file: %v", filename, err)
6871
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("⚠ Skipping %s: %s", filename, err.Error())))
6972
continue
7073
}
@@ -115,6 +118,7 @@ func GenerateActionMetadataCommand() error {
115118
generatedCount++
116119
}
117120

121+
generateActionMetadataLog.Printf("Action metadata generation complete: generated=%d, total=%d", generatedCount, len(targetFiles))
118122
if generatedCount == 0 {
119123
return errors.New("no actions were generated")
120124
}
@@ -282,6 +286,7 @@ func extractDependencies(content string) []string {
282286

283287
// generateActionYml generates an action.yml file
284288
func generateActionYml(actionDir string, metadata *ActionMetadata) error {
289+
generateActionMetadataLog.Printf("Generating action.yml: action=%s, inputs=%d, outputs=%d", metadata.ActionName, len(metadata.Inputs), len(metadata.Outputs))
285290
var content strings.Builder
286291

287292
fmt.Fprintf(&content, "name: '%s'\n", metadata.Name)
@@ -333,6 +338,7 @@ func generateActionYml(actionDir string, metadata *ActionMetadata) error {
333338

334339
// generateReadme generates a README.md file
335340
func generateReadme(actionDir string, metadata *ActionMetadata) error {
341+
generateActionMetadataLog.Printf("Generating README.md: action=%s, deps=%d", metadata.ActionName, len(metadata.Dependencies))
336342
var content strings.Builder
337343

338344
fmt.Fprintf(&content, "# %s\n\n", metadata.Name)

pkg/cli/trial_repository.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func ensureTrialRepository(repoSlug string, cloneRepoSlug string, forceDeleteHos
153153
}
154154

155155
func cleanupTrialRepository(repoSlug string, verbose bool) error {
156+
trialRepoLog.Printf("Cleaning up trial repository: %s", repoSlug)
156157
if verbose {
157158
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Cleaning up host repository: "+repoSlug))
158159
}
@@ -161,9 +162,11 @@ func cleanupTrialRepository(repoSlug string, verbose bool) error {
161162
output, err := workflow.RunGHCombined("Deleting repository...", "repo", "delete", repoSlug, "--yes")
162163

163164
if err != nil {
165+
trialRepoLog.Printf("Failed to delete trial repository %s: %v", repoSlug, err)
164166
return fmt.Errorf("failed to delete host repository: %w (output: %s)", err, string(output))
165167
}
166168

169+
trialRepoLog.Printf("Successfully deleted trial repository: %s", repoSlug)
167170
if verbose {
168171
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Deleted host repository: "+repoSlug))
169172
}
@@ -172,6 +175,7 @@ func cleanupTrialRepository(repoSlug string, verbose bool) error {
172175
}
173176

174177
func cloneTrialHostRepository(repoSlug string, verbose bool) (string, error) {
178+
trialRepoLog.Printf("Cloning trial host repository: %s", repoSlug)
175179
// Create temporary directory
176180
tempDir := filepath.Join(os.TempDir(), fmt.Sprintf("gh-aw-trial-%x", time.Now().UnixNano()))
177181

@@ -183,12 +187,15 @@ func cloneTrialHostRepository(repoSlug string, verbose bool) (string, error) {
183187

184188
// Clone the repository using the full slug
185189
repoURL := fmt.Sprintf("https://github.com/%s.git", repoSlug)
190+
trialRepoLog.Printf("Cloning repository from URL to tempDir: %s", tempDir)
186191

187192
output, err := workflow.RunGitCombined(fmt.Sprintf("Cloning %s...", repoSlug), "clone", repoURL, tempDir)
188193
if err != nil {
194+
trialRepoLog.Printf("Failed to clone host repository %s: %v", repoSlug, err)
189195
return "", fmt.Errorf("failed to clone host repository %s: %w (output: %s)", repoURL, err, string(output))
190196
}
191197

198+
trialRepoLog.Printf("Successfully cloned trial repository to: %s", tempDir)
192199
return tempDir, nil
193200
}
194201

@@ -333,6 +340,7 @@ type trialWorkflowWriteResult struct {
333340
// - Writing to destination
334341
// Returns the destination path and workflows directory for further processing.
335342
func writeWorkflowToTrialDir(tempDir string, workflowName string, content []byte, opts *TrialOptions) (*trialWorkflowWriteResult, error) {
343+
trialRepoLog.Printf("Writing workflow to trial dir: workflow=%s, content_size=%d bytes, securityScanDisabled=%v", workflowName, len(content), opts.DisableSecurityScanner)
336344
// Security scan: reject workflows containing malicious or dangerous content
337345
if !opts.DisableSecurityScanner {
338346
if findings := workflow.ScanMarkdownSecurity(string(content)); len(findings) > 0 {
@@ -387,6 +395,7 @@ func writeWorkflowToTrialDir(tempDir string, workflowName string, content []byte
387395

388396
// modifyWorkflowForTrialMode modifies the workflow to work in trial mode
389397
func modifyWorkflowForTrialMode(tempDir, workflowName, logicalRepoSlug string, verbose bool) error {
398+
trialRepoLog.Printf("Modifying workflow for trial mode: workflow=%s, logicalRepo=%s", workflowName, logicalRepoSlug)
390399
if verbose {
391400
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Modifying workflow for trial mode"))
392401
}

pkg/parser/import_field_extractor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func newImportAccumulator() *importAccumulator {
6767
// safe-inputs, steps, runtimes, services, network, permissions, secret-masking, bots,
6868
// skip-roles, skip-bots, plugins, post-steps, labels, cache, and features.
6969
func (acc *importAccumulator) extractAllImportFields(content []byte, item importQueueItem, visited map[string]bool) error {
70+
log.Printf("Extracting all import fields: path=%s, section=%s, inputs=%d, content_size=%d bytes", item.fullPath, item.sectionName, len(item.inputs), len(content))
7071
// Extract tools from imported file
7172
toolsContent, err := processIncludedFileWithVisited(item.fullPath, item.sectionName, true, visited)
7273
if err != nil {
@@ -112,6 +113,7 @@ func (acc *importAccumulator) extractAllImportFields(content []byte, item import
112113
// Extract engines from imported file
113114
engineContent, err := extractFrontmatterField(string(content), "engine", "")
114115
if err == nil && engineContent != "" {
116+
log.Printf("Found engine config in import: %s", item.fullPath)
115117
acc.engines = append(acc.engines, engineContent)
116118
}
117119

@@ -281,6 +283,8 @@ func (acc *importAccumulator) extractAllImportFields(content []byte, item import
281283
// toImportsResult converts the accumulated state to a final ImportsResult.
282284
// topologicalOrder is the result from topologicalSortImports.
283285
func (acc *importAccumulator) toImportsResult(topologicalOrder []string) *ImportsResult {
286+
log.Printf("Building ImportsResult: importedFiles=%d, importPaths=%d, engines=%d, bots=%d, plugins=%d, labels=%d",
287+
len(topologicalOrder), len(acc.importPaths), len(acc.engines), len(acc.bots), len(acc.plugins), len(acc.labels))
284288
return &ImportsResult{
285289
MergedTools: acc.toolsBuilder.String(),
286290
MergedMCPServers: acc.mcpServersBuilder.String(),

pkg/workflow/agent_validation.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ func (c *Compiler) validateMaxTurnsSupport(frontmatter map[string]any, engine Co
112112
return nil
113113
}
114114

115+
agentValidationLog.Printf("Validating max-turns support: engine=%s, maxTurns=%s", engine.GetID(), engineConfig.MaxTurns)
116+
115117
// max-turns is specified, check if the engine supports it
116118
if !engine.SupportsMaxTurns() {
119+
agentValidationLog.Printf("Engine %s does not support max-turns feature", engine.GetID())
117120
return fmt.Errorf("max-turns not supported: engine '%s' does not support the max-turns feature", engine.GetID())
118121
}
119122

@@ -133,8 +136,11 @@ func (c *Compiler) validateMaxContinuationsSupport(frontmatter map[string]any, e
133136
return nil
134137
}
135138

139+
agentValidationLog.Printf("Validating max-continuations support: engine=%s, maxContinuations=%d", engine.GetID(), engineConfig.MaxContinuations)
140+
136141
// max-continuations is specified, check if the engine supports it
137142
if !engine.SupportsMaxContinuations() {
143+
agentValidationLog.Printf("Engine %s does not support max-continuations feature", engine.GetID())
138144
return fmt.Errorf("max-continuations not supported: engine '%s' does not support the max-continuations feature", engine.GetID())
139145
}
140146

@@ -151,8 +157,11 @@ func (c *Compiler) validateWebSearchSupport(tools map[string]any, engine CodingA
151157
return
152158
}
153159

160+
agentValidationLog.Printf("Validating web-search support for engine: %s", engine.GetID())
161+
154162
// web-search is specified, check if the engine supports it
155163
if !engine.SupportsWebSearch() {
164+
agentValidationLog.Printf("Engine %s does not natively support web-search tool, emitting warning", engine.GetID())
156165
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Engine '%s' does not support the web-search tool. See https://github.github.com/gh-aw/guides/web-search/ for alternatives.", engine.GetID())))
157166
c.IncrementWarningCount()
158167
}

pkg/workflow/compiler_safe_outputs_core.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func (c *Compiler) hasCustomTokenSafeOutputs(safeOutputs *SafeOutputsConfig) boo
2121
if safeOutputs.UpdateProjects != nil ||
2222
safeOutputs.CreateProjects != nil ||
2323
safeOutputs.CreateProjectStatusUpdates != nil {
24+
consolidatedSafeOutputsLog.Print("Custom token required: project-related safe outputs detected")
2425
return true
2526
}
2627

@@ -31,16 +32,19 @@ func (c *Compiler) hasCustomTokenSafeOutputs(safeOutputs *SafeOutputsConfig) boo
3132
// the npm install.
3233
for _, base := range c.collectBaseSafeOutputConfigs(safeOutputs) {
3334
if base != nil && base.GitHubToken != "" {
35+
consolidatedSafeOutputsLog.Print("Custom token required: per-handler github-token configured")
3436
return true
3537
}
3638
}
3739

40+
consolidatedSafeOutputsLog.Print("No custom token required for safe outputs")
3841
return false
3942
}
4043

4144
// collectBaseSafeOutputConfigs returns pointers to the BaseSafeOutputConfig
4245
// embedded in every configured safe output type. Nil entries are skipped by callers.
4346
func (c *Compiler) collectBaseSafeOutputConfigs(so *SafeOutputsConfig) []*BaseSafeOutputConfig {
47+
consolidatedSafeOutputsLog.Print("Collecting base safe output configs for custom token check")
4448
var configs []*BaseSafeOutputConfig
4549
if so.CreateIssues != nil {
4650
configs = append(configs, &so.CreateIssues.BaseSafeOutputConfig)
@@ -156,6 +160,7 @@ func (c *Compiler) collectBaseSafeOutputConfigs(so *SafeOutputsConfig) []*BaseSa
156160
if so.NoOp != nil {
157161
configs = append(configs, &so.NoOp.BaseSafeOutputConfig)
158162
}
163+
consolidatedSafeOutputsLog.Printf("Collected %d base safe output configs", len(configs))
159164
return configs
160165
}
161166

0 commit comments

Comments
 (0)