Skip to content

Commit a32cb12

Browse files
Copilotpelikhan
andauthored
Add fork context hint to workflow failure conclusion messages (#18529)
* Initial plan * Add fork context hint to workflow failure conclusion messages When a gh-aw workflow fails in a fork repository, append a hint to the failure issue/comment body explaining that secrets from the parent repository are not inherited. - Add buildForkContextHint() in handle_agent_failure.cjs that checks context.payload?.repository?.fork using optional chaining - Add fork_context to templateContext for both new issue creation and existing issue comment paths - Update agent_failure_issue.md and agent_failure_comment.md templates to include the {fork_context} placeholder Closes part of #18481 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 51b1423 commit a32cb12

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

actions/setup/js/handle_agent_failure.cjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ function buildCreateDiscussionErrorsContext(createDiscussionErrors) {
290290
return context;
291291
}
292292

293+
/**
294+
* Build a fork context hint string when the repository is a fork.
295+
* @returns {string} Fork hint string, or empty string if not a fork
296+
*/
297+
function buildForkContextHint() {
298+
if (context.payload?.repository?.fork) {
299+
return "\n💡 **This repository is a fork.** If this failure is due to missing API keys or tokens, note that secrets from the parent repository are not inherited. Configure the required secrets directly in your fork's Settings → Secrets and variables → Actions.\n";
300+
}
301+
return "";
302+
}
303+
293304
/**
294305
* Build a context string describing code-push failures for inclusion in failure issue/comment bodies.
295306
* @param {string} codePushFailureErrors - Newline-separated list of "type:error" entries
@@ -617,6 +628,9 @@ async function main() {
617628
missingSafeOutputsContext += "- The agent should have called `noop` to explicitly indicate no action was taken\n\n";
618629
}
619630

631+
// Build fork context hint
632+
const forkContext = buildForkContextHint();
633+
620634
// Create template context
621635
const templateContext = {
622636
run_url: runUrl,
@@ -635,6 +649,7 @@ async function main() {
635649
repo_memory_validation_context: repoMemoryValidationContext,
636650
missing_data_context: missingDataContext,
637651
missing_safe_outputs_context: missingSafeOutputsContext,
652+
fork_context: forkContext,
638653
};
639654

640655
// Render the comment template
@@ -725,6 +740,9 @@ async function main() {
725740
missingSafeOutputsContext += "- The agent should have called `noop` to explicitly indicate no action was taken\n\n";
726741
}
727742

743+
// Build fork context hint
744+
const forkContext = buildForkContextHint();
745+
728746
// Create template context with sanitized workflow name
729747
const templateContext = {
730748
workflow_name: sanitizedWorkflowName,
@@ -744,6 +762,7 @@ async function main() {
744762
repo_memory_validation_context: repoMemoryValidationContext,
745763
missing_data_context: missingDataContext,
746764
missing_safe_outputs_context: missingSafeOutputsContext,
765+
fork_context: forkContext,
747766
};
748767

749768
// Render the issue template
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Agent job [{run_id}]({run_url}) failed.
22

3-
{secret_verification_context}{assignment_errors_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{missing_data_context}{missing_safe_outputs_context}
3+
{secret_verification_context}{assignment_errors_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{missing_data_context}{missing_safe_outputs_context}{fork_context}

actions/setup/md/agent_failure_issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Branch:** {branch}
55
**Run:** {run_url}{pull_request_info}
66

7-
{secret_verification_context}{assignment_errors_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{missing_data_context}{missing_safe_outputs_context}
7+
{secret_verification_context}{assignment_errors_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{missing_data_context}{missing_safe_outputs_context}{fork_context}
88

99
### Action Required
1010

0 commit comments

Comments
 (0)