Conversation
…and remove buildCommandOnlyCondition Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
BuildSafeOutputType("create-issue").Render()
- remove buildCommandOnlyCondition as it is already ch...…move buildCommandOnlyCondition as requested Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
I've updated the implementation to retain the original base expressions and AND them with the safe output type condition as requested. The buildCommandOnlyCondition has been removed while preserving all Target-based logic. For example, add-comment jobs now generate conditions like:
Fixed in commit 332dfbb. |
| } | ||
| safeOutputCondition := BuildSafeOutputType("add-comment").Render() | ||
|
|
||
| if baseCondition == "always()" { |
There was a problem hiding this comment.
Removed the always() condition. When Target == "*", the job now uses just the safe output type condition without the always() wrapper.
Fixed in commit e92f392.
|
|
||
| // Determine the job condition for command workflows | ||
| // Combine the base condition with the safe output type condition | ||
| var baseCondition = "github.event.issue.number || github.event.pull_request.number" // Only run in issue or PR context |
There was a problem hiding this comment.
@copilot use Disjunction, Conjunction helpers to build expression tree and render once.
There was a problem hiding this comment.
Updated to use AndNode and OrNode expression tree builders instead of string concatenation. All safe-output job functions now build expression trees and call .Render() once at the end.
For example, add_labels now generates:
baseCondition := &OrNode{
Left: &ExpressionNode{Expression: "github.event.issue.number"},
Right: &ExpressionNode{Expression: "github.event.pull_request.number"},
}
jobCondition := &AndNode{
Left: safeOutputCondition,
Right: baseCondition,
}Fixed in commit e92f392.
…or building conditions Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| issueWithPR := &AndNode{ | ||
| Left: &ExpressionNode{Expression: "github.event.issue.number"}, | ||
| Right: &ExpressionNode{Expression: "github.event.issue.pull_request"}, | ||
| } |
There was a problem hiding this comment.
Removed the Target == "*" special case. The job now always combines the safe output condition with the base PR context condition, regardless of the Target setting.
Generated condition: (contains(needs.agent.outputs.output_types, 'push-to-pull-request-branch')) && (((github.event.issue.number) && (github.event.issue.pull_request)) || (github.event.pull_request))
Fixed in commit 0eb1432.
| // Combine safe output condition AND issue number exists | ||
| baseCondition := &ExpressionNode{Expression: "github.event.issue.number"} | ||
| jobCondition = &AndNode{ | ||
| Left: safeOutputCondition, |
There was a problem hiding this comment.
Removed the Target == "*" and explicit target special cases. The job now always combines the safe output condition with the issue number base condition.
Generated condition: (contains(needs.agent.outputs.output_types, 'update-issue')) && (github.event.issue.number)
Fixed in commit 0eb1432.
…ndition Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…oss multiple workflows
…tps://github.com/githubnext/gh-aw into copilot/fix-d8e61a3d-9fad-42d6-82a3-ae4872557728
|
review the generated if condition for each safe output type and ensure it is consistent with the safe output type specification report potential issues |
Reviewed all safe-output job conditions. No issues found - all conditions are consistent with their specifications. Summary by Category✅ Target-Aware Safe-Outputs (Context Required by Default)add-comment, add-labels, update-issue - Add base context condition when Target is empty:
Note: add-labels uses ✅ Creation Safe-Outputs (No Context Required)create-issue, create-pull-request, create-discussion, upload-asset, create-code-scanning-alert - Always just output type check:
These create new resources, so don't need triggering context. ✅ PR-Specific Safe-Outputs (Always Require PR Context)create-pull-request-review-comment, push-to-pull-request-branch - Always enforce PR context:
No Target support - these operations require an existing PR. All conditions correctly match their intended behavior. |
|
@copilot BuildSafeOutputType should also have always() to run even when the agent process failed. |
…ent fails Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated Generated condition format: if: (always()) && (contains(needs.agent.outputs.output_types, 'add-comment'))This ensures safe-output jobs run even when the agent process fails, allowing them to process any outputs generated before the failure. Changes:
Fixed in commit 995b2d0. |
|
@copilot format, lint, recompile |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed formatting, linting, and recompiling:
All checks pass and workflows are up to date. Fixed in commit bac0436. |
| missing_tool: | ||
| needs: agent | ||
| if: ${{ always() }} | ||
| if: (always()) && (contains(needs.agent.outputs.output_types, 'create-pull-request')) |
There was a problem hiding this comment.
@copilot 'missing-tool' should be 'create-pull-request'
There was a problem hiding this comment.
Fixed. The missing_tool job now uses BuildSafeOutputType("missing-tool") instead of a hardcoded condition, generating the correct output type check: (always()) && (contains(needs.agent.outputs.output_types, 'missing-tool'))
Fixed in commit 3afabd2.
…ype 'missing-tool' Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot merge main, format, lint , recompile |
…ot/fix-d8e61a3d-9fad-42d6-82a3-ae4872557728
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed merge from main, formatting, linting, and recompilation:
All checks pass and workflows are up to date. Fixed in commit 0c0e9f4. |
This PR refactors the conditional logic for safe-output job creation functions to use expression tree builders (
AndNode/OrNode) instead of string concatenation, while addingalways()wrapper to ensure safe-output jobs run even when the agent fails, removing redundant command-based filtering, and adding complete Target support to add-labels including both Go compiler and JavaScript implementation.Problem
Safe-output job creation functions were using inconsistent and complex conditional logic that had several issues:
buildCommandOnlyCondition(redundant - already handled by activation job)fmt.Sprintffor building conditionsalways()wrapper whenTarget == "*"Solution
Refactored to use expression tree builders and added
always()wrapper for robust failure handling:BuildSafeOutputType with always() wrapper:
Generated Condition:
Fixed missing_tool.go:
Changes
BuildSafeOutputTypefunction - Now wraps the output type check withalways() &&to ensure safe-output jobs run even when agent failsBuildSafeOutputType("missing-tool")instead of hardcoded"${{ always() }}"AndNode,OrNode,ExpressionNode)Targethandling - now checks if Target is empty (== "") to decide whether to add base conditiontargetfield in AddLabelsConfig, consistent with update-issue behaviorGITHUB_AW_LABELS_TARGETand handles all three target modes (triggering/*/explicit number)"publish-assets"to"upload-asset"to match registered output typetargetproperty to add-labels configuration in JSON schemafmt.Sprintfwith proper expression tree compositionbuildCommandOnlyConditionfunction - command filtering now handled by activation jobcreate_issue_commentrenamed toadd_commentfor consistencyalways()in all safe-output job conditionsmake fmtandmake fmt-cjsto format Go and JavaScript filesmake lint(JavaScript with prettier, Go with golangci-lint)make recompileto regenerate all.lock.ymlfiles with updated conditionsTarget Support Validation
All three safe-output types (add-comment, add-labels, update-issue) now have complete and consistent Target support:
Go Compiler:
JavaScript Implementation:
Benefits
BuildSafeOutputTypeTargethandling: Base condition only added when Target is not explicitly set.lock.ymlfiles regenerated with latest codeThe activation job already handles command filtering and outputs the appropriate
output_types, so safe-output jobs can simply check if their specific output type is requested while conditionally respecting their base context conditions based on the Target setting. Thealways()wrapper ensures these jobs run regardless of agent job status, allowing them to process any outputs that were generated before a potential failure.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.