Fix agent job needs not populated from engine.env needs expressions#30239
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0d59bfbd-af1d-4dbb-929a-9387b68a271e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
When engine.env values contain needs.<job>.outputs.* expressions, the referenced custom jobs are now scanned and added as direct dependencies of the agent job — matching the existing behavior for markdown content and custom steps. Additionally, emit a warning when engine.env values reference built-in jobs (e.g., detection, safe_outputs) via needs expressions, since those jobs cannot be added as direct agent dependencies and the expression would silently evaluate to empty at runtime. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0d59bfbd-af1d-4dbb-929a-9387b68a271e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a compilation gap where engine.env values containing needs.<job>.outputs.* were not considered when computing the agent job’s direct needs, leading to those expressions evaluating to empty strings at runtime.
Changes:
- Extend agent job dependency scanning in
buildMainJobto include allengine.envvalues. - Emit a compiler warning when
engine.envreferences built-in jobs vianeeds.*expressions. - Add unit + end-to-end compilation tests covering the
engine.envdependency behavior.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/compiler_main_job.go | Includes engine.env values in the referenced-job scan so the agent job needs list is correctly populated; adds warnings for built-in job references in engine.env. |
| pkg/workflow/compiler_jobs_test.go | Adds tests ensuring engine.env needs-expressions add custom jobs to agent needs and don’t duplicate entries; includes an end-to-end compilation assertion. |
| .github/workflows/metrics-collector.lock.yml | Regenerates the lock workflow output (adds GH_AW_INFO_VERSION in a setup step env block). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
| builtinNames := make([]string, 0, len(constants.KnownBuiltInJobNames)) | ||
| for name := range constants.KnownBuiltInJobNames { | ||
| builtinNames = append(builtinNames, name) | ||
| } | ||
| sort.Strings(builtinNames) | ||
| builtinsWarned := make(map[string]bool) | ||
| for _, builtinJobName := range builtinNames { | ||
| if !builtinsWarned[builtinJobName] && strings.Contains(engineEnvContent, fmt.Sprintf("needs.%s.", builtinJobName)) { |
|
@copilot review all comments |
When engine.env references a built-in job that is already a direct dependency of the agent job (e.g., activation), skip the warning. The warning now only fires for built-in jobs that are not in the agent's depends list — i.e., those that would silently produce empty strings at runtime. Add a regression test to verify that activation references in engine.env do not trigger a spurious warning. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/abe615eb-6bb4-4ba0-a6c3-b3c8b4f10821 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in 7e3bc98. The warning now skips any built-in job already present in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot add integration workflow tests in pkg/cli/workflows |
…cli/workflows - Add test fixture: test-engine-env-needs.md — a workflow where engine.env references provide_value_to_agent via a needs expression - Add integration test: TestCompileEngineEnvNeedsExpression — compiles the fixture and asserts that the agent job's needs list includes both activation and provide_value_to_agent Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d869ed3d-87d8-4270-8065-3d4371b6aaae Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added in d4f67c8:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
engine.envvalues containingneeds.<job>.outputs.*expressions were silently ignored during compilation — referenced custom jobs were never added to the agent job'sneedslist, causing those expressions to evaluate to empty strings at runtime.Changes
compiler_main_job.go: Extend the custom-job reference scan inbuildMainJobto include allengine.envvalues in addition to markdown content and custom steps. Engine env content is computed once and reused for:needsdependencies of the agent jobengine.envvalues reference built-in jobs (detection,safe_outputs, etc.) that cannot be wired as direct agent dependencies — built-in jobs already present as direct dependencies (e.g.,activation) are correctly excluded from this warningExample
Given this frontmatter:
Before:
agent.needs = [activation]→needs.provide_value_to_agentisundefinedat runtime.After:
agent.needs = [activation, provide_value_to_agent]→ expression evaluates correctly.Tests
engine.envreference adds custom job as direct dependencyengine.envand normal contentengine.envreferencesactivation(already a direct dependency)pkg/workflow): end-to-end compilation of the exact bug-report scenariopkg/cli): compilestest-engine-env-needs.mdfixture and assertsprovide_value_to_agentappears in the agent job'sneeds