Skip to content

Resolve triggering safe outputs from centralized workflow_dispatch context#39580

Merged
pelikhan merged 8 commits into
mainfrom
copilot/update-issue-safe-output-fail
Jun 16, 2026
Merged

Resolve triggering safe outputs from centralized workflow_dispatch context#39580
pelikhan merged 8 commits into
mainfrom
copilot/update-issue-safe-output-fail

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Centralized slash_command routing dispatches child workflows as workflow_dispatch, which drops github.event.issue from the runtime payload. As a result, update_issue with target: triggering could skip while add_comment still succeeded via aw_context, causing partial safe-output delivery and failed runs.

  • Use normalized invocation context for target: triggering

    • Teach shared safe-output target resolution to derive the effective event name/payload from workflow_dispatch relay metadata via resolveInvocationContext().
    • This lets issue/PR-targeted handlers resolve the original triggering item from aw_context instead of depending on raw github.event.* fields.
  • Unify issue/PR fallback resolution across handlers

    • Update add_labels and remove_labels to use the same normalized invocation context for implicit target fallback.
    • This aligns their behavior with add_comment and avoids handler-specific drift when workflows are dispatched centrally.
  • Cover centralized dispatch regressions

    • Add focused tests for:
      • shared resolveTarget() behavior on workflow_dispatch + aw_context
      • update_issue resolving the triggering issue without an explicit issue_number
      • add_labels / remove_labels resolving issue context from relayed dispatch metadata
const result = resolveTarget({
  targetConfig: "triggering",
  item: {},
  context: {
    eventName: "workflow_dispatch",
    payload: {
      inputs: {
        aw_context: JSON.stringify({
          event_type: "issue_comment",
          item_type: "issue",
          item_number: 321,
          repo: "owner/repo",
        }),
      },
    },
  },
  itemType: "update_issue",
  supportsIssue: true,
});

This change is intended to make update_issue, add_labels, and remove_labels behave consistently with existing comment delivery in centralized slash-command workflows.

Copilot AI and others added 2 commits June 16, 2026 16:00
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix update issue safe output failure on workflow_dispatch Resolve triggering safe outputs from centralized workflow_dispatch context Jun 16, 2026
Copilot AI requested a review from pelikhan June 16, 2026 16:12
@pelikhan pelikhan marked this pull request as ready for review June 16, 2026 16:26
Copilot AI review requested due to automatic review settings June 16, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses centralized slash_command workflows that relay into child workflows via workflow_dispatch, where github.event.issue/pull_request can be missing. It normalizes how safe-output handlers infer the original triggering issue/PR using relayed aw_context, and adds regression tests to cover the centralized-dispatch path.

Changes:

  • Update shared safe-output target resolution to derive effective eventName/payload via resolveInvocationContext() (including workflow_dispatch + aw_context).
  • Align add_labels and remove_labels fallback target resolution with the normalized invocation context.
  • Add tests covering workflow_dispatch relays for resolveTarget(), update_issue, add_labels, and remove_labels.
Show a summary per file
File Description
actions/setup/js/safe_output_helpers.cjs Uses normalized invocation context when resolving “triggering” targets.
actions/setup/js/safe_output_helpers.test.cjs Adds coverage for resolving workflow_dispatch issue context from aw_context.
actions/setup/js/update_issue.test.cjs Adds a regression test ensuring update_issue resolves triggering issue from relayed aw_context.
actions/setup/js/add_labels.cjs Uses normalized invocation payload for implicit issue/PR fallback resolution.
actions/setup/js/add_labels.test.cjs Adds coverage for add_labels resolving issue number from workflow_dispatch aw_context.
actions/setup/js/remove_labels.cjs Uses normalized invocation payload for implicit issue/PR fallback resolution.
actions/setup/js/remove_labels.test.cjs Adds coverage for remove_labels resolving issue number from workflow_dispatch aw_context.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 2

Comment on lines +74 to +76
const invocationContext = resolveInvocationContext(context);
const effectiveEventName = invocationContext?.eventName || context.eventName;
const effectivePayload = invocationContext?.eventPayload || context.payload;
Comment on lines +782 to +806
mockContext.eventName = "workflow_dispatch";
mockContext.payload = {
inputs: {
aw_context: JSON.stringify({
event_type: "issue_comment",
item_type: "issue",
item_number: 123,
repo: "testowner/testrepo",
}),
},
};
let capturedIssueNumber;

mockGithub.rest.issues.get.mockResolvedValue({
data: { number: 123, title: "Test", body: "Original", html_url: "https://github.com/testowner/testrepo/issues/123" },
});
mockGithub.rest.issues.update.mockImplementation(async ({ issue_number, body }) => {
capturedIssueNumber = issue_number;
return { data: { number: issue_number, title: "Test", body, html_url: `https://github.com/testowner/testrepo/issues/${issue_number}` } };
});

const { main } = await import("./update_issue.cjs");
const handler = await main();
const result = await handler({ body: "Updated from centralized dispatch" }, {});

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@pelikhan pelikhan merged commit 59da4a4 into main Jun 16, 2026
14 checks passed
@pelikhan pelikhan deleted the copilot/update-issue-safe-output-fail branch June 16, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants