Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions actions/setup/js/handle_agent_failure.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,17 @@ function buildCreateDiscussionErrorsContext(createDiscussionErrors) {
return context;
}

/**
* Build a fork context hint string when the repository is a fork.
* @returns {string} Fork hint string, or empty string if not a fork
*/
function buildForkContextHint() {
if (context.payload?.repository?.fork) {
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";
}
return "";
Comment on lines +297 to +301
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New fork-context behavior is introduced here but handle_agent_failure.cjs currently has no unit tests. Given the repo’s extensive Vitest coverage for other action scripts, please add a focused test that asserts the rendered issue/comment body includes the fork hint when context.payload.repository.fork === true and remains unchanged (no hint) when false/undefined.

Copilot uses AI. Check for mistakes.
}

/**
* Build a context string describing code-push failures for inclusion in failure issue/comment bodies.
* @param {string} codePushFailureErrors - Newline-separated list of "type:error" entries
Expand Down Expand Up @@ -617,6 +628,9 @@ async function main() {
missingSafeOutputsContext += "- The agent should have called `noop` to explicitly indicate no action was taken\n\n";
}

// Build fork context hint
const forkContext = buildForkContextHint();

// Create template context
const templateContext = {
run_url: runUrl,
Expand All @@ -635,6 +649,7 @@ async function main() {
repo_memory_validation_context: repoMemoryValidationContext,
missing_data_context: missingDataContext,
missing_safe_outputs_context: missingSafeOutputsContext,
fork_context: forkContext,
};

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

// Build fork context hint
const forkContext = buildForkContextHint();

// Create template context with sanitized workflow name
const templateContext = {
workflow_name: sanitizedWorkflowName,
Expand All @@ -744,6 +762,7 @@ async function main() {
repo_memory_validation_context: repoMemoryValidationContext,
missing_data_context: missingDataContext,
missing_safe_outputs_context: missingSafeOutputsContext,
fork_context: forkContext,
};

// Render the issue template
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/md/agent_failure_comment.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Agent job [{run_id}]({run_url}) failed.

{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}
{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}
2 changes: 1 addition & 1 deletion actions/setup/md/agent_failure_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Branch:** {branch}
**Run:** {run_url}{pull_request_info}

{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}
{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}

### Action Required

Expand Down
Loading