Skip to content

GH_AW_WORKFLOWS_DIR env override silently bypassed at 5 filepath.Join sites #32545

@github-actions

Description

@github-actions

Summary

The GH_AW_WORKFLOWS_DIR env-var override that constants.GetWorkflowDir() honors (pkg/constants/constants.go:338-343) is silently bypassed at 5 production call sites that assemble the workflows path with filepath.Join(*, ".github", "workflows") instead of using the helper. Setting the env var to e.g. custom/dir produces inconsistent runtime behavior: most code paths look at the override, but these 5 paths keep looking at .github/workflows.

Cross-reference: continuation of #aw_sg9a1 (Run 9) which fixed the helper itself.

Locations

Real bugs (env override does not take effect):

  • pkg/workflow/dispatch_workflow_file_resolver.go:70searchDir := filepath.Join(repoRoot, ".github", "workflows") — the actual search directory for dispatch workflow resolution.
  • pkg/cli/copilot_setup.go:186workflowsDir := filepath.Join(".github", "workflows") — passed to os.MkdirAll, so the directory created on disk doesn't honor the override.
  • pkg/cli/init.go:214workflowsDir := filepath.Join(gitRoot, ".github", "workflows") — used in os.Stat early-exit check for maintenance-workflow generation.

Lower severity (error-message construction only):

  • pkg/workflow/dispatch_workflow_validation.go:61
  • pkg/workflow/call_workflow_validation.go:75

Impact

  • Severity: High — the env-override is a documented public contract (pkg/constants/README.md:349) that takes effect only partially.
  • User-visible failure mode: a user setting GH_AW_WORKFLOWS_DIR=custom/dir sees workflows correctly resolved by the compiler, but dispatch_workflow_file_resolver searches the wrong directory, copilot_setup creates .github/workflows instead of custom/dir, and init skips maintenance-workflow generation because it stats the wrong path.
  • Affected files: 5 prod files (3 real bugs, 2 cosmetic).

Recommendation

Replace filepath.Join(*, ".github", "workflows") with filepath.Join(*, constants.GetWorkflowDir()) at every site. Example:

Before:

searchDir := filepath.Join(repoRoot, ".github", "workflows")

After:

searchDir := filepath.Join(repoRoot, constants.GetWorkflowDir())

Note: GetWorkflowDir() already returns a forward-slash path, so filepath.Join normalizes correctly per-OS.

Validation

  • Set GH_AW_WORKFLOWS_DIR=custom/dir, run gh aw copilot-setup — verify custom/dir/copilot-setup-steps.yml is created (not .github/workflows/...).
  • Run existing dispatch-workflow tests with override set — verify resolution succeeds.
  • Grep ensures no filepath.Join(*, ".github", "workflows") left in pkg/ non-test.

References:

  • §25953081117
  • Prior issue #aw_sg9a1 (env-var support landed in constants.GetWorkflowDir)

Generated by Sergo — Run 11

Generated by 🤖 Sergo - Serena Go Expert · ● 15.6M ·

  • expires on May 23, 2026, 4:57 AM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions