Skip to content

Commit 886aadd

Browse files
Add debug logging to add-workflow code paths (#61710)
1 parent 331bd89 commit 886aadd

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

pkg/cli/add_command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ func rejectBootstrapProfileForRegularAdd(sources []string, profile *resolvedBoot
204204
requestedSources = profile.PackageID
205205
}
206206

207+
addLog.Printf("Rejecting plain add for package %s: aw.yml config requires add-wizard", profile.PackageID)
207208
return fmt.Errorf("package %s declares aw.yml config, so 'gh aw add' cannot run its interactive setup. Expected interactive setup via add-wizard for packages with aw.yml config. Example: gh aw add-wizard %s", profile.PackageID, requestedSources)
208209
}
209210

pkg/cli/add_interactive_orchestrator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func RunAddInteractive(ctx context.Context, config *AddInteractiveConfig) error
115115
// Local writes stop before remote-only follow-up: repository secret updates,
116116
// bootstrap mutations, workflow status polling, and optional dispatch all require
117117
// the workflow changes to be present on GitHub.
118+
addInteractiveLog.Print("User chose to write files locally; skipping PR and remote follow-up steps")
118119
printBootstrapConfigTODO(os.Stderr, remainingBootstrapProfile)
119120
config.showLocalWriteInstructions()
120121
return nil
@@ -162,8 +163,10 @@ func (c *AddInteractiveConfig) applyBootstrapConfigIfNeeded(ctx context.Context,
162163
return nil
163164
}
164165
if c.hasWriteAccess {
166+
addInteractiveLog.Print("Applying bootstrap config: user has write access")
165167
return executeBootstrapConfigForAdd(ctx, c.RepoOverride, c.WorkflowSpecs, profile, c.UseCopilotRequests, c.Verbose, c.DisableGitHubAppPermissionInference)
166168
}
169+
addInteractiveLog.Print("Skipping bootstrap config application: user lacks write access")
167170
printBootstrapConfigTODO(os.Stderr, profile)
168171
return nil
169172
}
@@ -240,6 +243,7 @@ func (c *AddInteractiveConfig) prepareAndConfirmAddInteractive() (workflowFiles
240243
}
241244

242245
if !createPR {
246+
addInteractiveLog.Print("Wizard stopping before init/secret steps: user declined PR creation")
243247
return workflowFiles, nil, "", "", false, nil
244248
}
245249

pkg/cli/add_package_manifest_skills.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func resolvePackageSkillDirFiles(ctx context.Context, owner, repo, ref, host, sk
126126
// auto-scanned for .md files.
127127
func resolvePackageAgentFiles(ctx context.Context, owner, repo, packagePath, ref, host string, explicitAgentFiles []string) ([]string, []string, error) {
128128
if len(explicitAgentFiles) > 0 {
129+
addPackageManifestLog.Printf("Using %d explicit agent file(s) from manifest for %s/%s", len(explicitAgentFiles), owner, repo)
129130
var agentFiles []string
130131
for _, f := range explicitAgentFiles {
131132
if strings.HasPrefix(filepath.ToSlash(f), constants.GithubDir) {
@@ -153,6 +154,7 @@ func resolvePackageAgentFiles(ctx context.Context, owner, repo, packagePath, ref
153154
}
154155
}
155156
}
157+
addPackageManifestLog.Printf("Auto-scanned %d agent file(s) for %s/%s (path=%q)", len(agentFiles), owner, repo, packagePath)
156158
return agentFiles, nil, nil
157159
}
158160

@@ -214,6 +216,7 @@ func scanRepositoryPackageInstallablePaths(ctx context.Context, owner, repo, pac
214216
}
215217
}
216218

219+
addPackageManifestLog.Printf("Scanned %d installable path(s) under %s/%s (path=%q)", len(collected), owner, repo, packagePath)
217220
return collected, nil
218221
}
219222

@@ -224,6 +227,7 @@ func resolveRepositoryPackageDocsPath(ctx context.Context, owner, repo, packageP
224227
if _, err := downloadPackageFileFromGitHubForHost(ctx, owner, repo, readmePath, ref, host); err == nil {
225228
return readmePath, nil
226229
} else if isRepositoryFileNotFound(err) {
230+
addPackageManifestLog.Printf("Package %s missing required README.md at %q", packageID, readmePath)
227231
return "", fmt.Errorf("repository %q is not a valid Agentic Workflow package: missing required README.md at %q. Add a README.md describing the package. Example:\n# My Package\n\nDescribe what this package does", packageID, readmePath)
228232
} else {
229233
return "", fmt.Errorf("failed to read package README %q from %s/%s@%s (check the repository, ref, and network connectivity): %w", readmePath, owner, repo, ref, err)

pkg/cli/add_workflow_content.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ func validateWorkflowDestination(githubWorkflowsDir, workflowName, sourceRepo st
3737
if sourceRepo != "" {
3838
existingSourceRepo := readSourceRepoFromFile(existingFile)
3939
if existingSourceRepo == sourceRepo {
40+
addLog.Printf("Destination %s already exists from same source repo %s, skipping", existingFile, sourceRepo)
4041
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Workflow from same source already exists, skipping: "+existingFile))
4142
return true, nil
4243
}
4344
}
4445
if opts.FromWildcard {
46+
addLog.Printf("Destination %s already exists, skipping due to wildcard add", existingFile)
4547
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Workflow '%s' already exists in .github/workflows/. Skipping.", workflowName)))
4648
return true, nil
4749
}
50+
addLog.Printf("Destination %s already exists and force/wildcard not set, rejecting", existingFile)
4851
return false, fmt.Errorf("workflow '%s' already exists in .github/workflows/. Use a different name with -n flag, remove the existing workflow first, or use --force to overwrite", workflowName)
4952
}
5053

@@ -85,15 +88,19 @@ func compileAddedWorkflow(ctx context.Context, destFile string, workflowSpec *Wo
8588
func validateWorkflowSecurity(resolved *ResolvedWorkflow, opts AddOptions) error {
8689
if !opts.DisableSecurityScanner {
8790
if findings := workflow.ScanMarkdownSecurity(string(resolved.Content)); len(findings) > 0 {
91+
addLog.Printf("Security scan failed for %s: %d finding(s)", resolved.Spec.WorkflowPath, len(findings))
8892
fmt.Fprintln(os.Stderr, console.FormatErrorMessage("Security scan failed for workflow"))
8993
fmt.Fprintln(os.Stderr, workflow.FormatSecurityFindings(findings, resolved.Spec.WorkflowPath))
9094
return fmt.Errorf("workflow '%s' failed security scan: %d issue(s) detected", resolved.Spec.WorkflowPath, len(findings))
9195
}
9296
if opts.Verbose {
9397
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Security scan passed"))
9498
}
95-
} else if opts.Verbose {
96-
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Security scanning disabled"))
99+
} else {
100+
addLog.Print("Security scanning disabled for this add")
101+
if opts.Verbose {
102+
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Security scanning disabled"))
103+
}
97104
}
98105
return nil
99106
}
@@ -121,9 +128,11 @@ func fetchWorkflowDependencies(ctx context.Context, workflowSpec *WorkflowSpec,
121128
// For remote workflows, fetch and save all dependencies (includes, imports, dispatch workflows, resources)
122129
if workflowSpec.RawURL != "" {
123130
// Generic URL imports carry no GitHub repo context; dependency fetching is skipped.
131+
addLog.Print("Skipping dependency fetch: raw URL workflow spec")
124132
return nil
125133
}
126134
if !isLocalWorkflowPath(workflowSpec.WorkflowPath) {
135+
addLog.Printf("Fetching remote dependencies for %s", workflowSpec.WorkflowPath)
127136
return fetchAllRemoteDependencies(ctx, string(sourceContent), workflowSpec, githubWorkflowsDir, opts.Verbose, opts.Force, tracker)
128137
}
129138
if sourceInfo == nil || !sourceInfo.IsLocal {
@@ -325,6 +334,7 @@ func trackAndWriteWorkflowFile(destFile string, content string, fileExists bool,
325334
if err != nil {
326335
return fmt.Errorf("failed to read back destination file '%s': %w", destFile, err)
327336
}
337+
addLog.Printf("Wrote workflow file %s (%d bytes, existed=%t)", destFile, len(writtenContent), fileExists)
328338
if !opts.Quiet {
329339
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Added workflow: "+filepath.Base(destFile)))
330340
if opts.Verbose {

0 commit comments

Comments
 (0)