Resolve triggering safe outputs from centralized workflow_dispatch context#39580
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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 viaresolveInvocationContext()(includingworkflow_dispatch+aw_context). - Align
add_labelsandremove_labelsfallback target resolution with the normalized invocation context. - Add tests covering
workflow_dispatchrelays forresolveTarget(),update_issue,add_labels, andremove_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" }, {}); | ||
|
|
Collaborator
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Centralized
slash_commandrouting dispatches child workflows asworkflow_dispatch, which dropsgithub.event.issuefrom the runtime payload. As a result,update_issuewithtarget: triggeringcould skip whileadd_commentstill succeeded viaaw_context, causing partial safe-output delivery and failed runs.Use normalized invocation context for
target: triggeringworkflow_dispatchrelay metadata viaresolveInvocationContext().aw_contextinstead of depending on rawgithub.event.*fields.Unify issue/PR fallback resolution across handlers
add_labelsandremove_labelsto use the same normalized invocation context for implicit target fallback.add_commentand avoids handler-specific drift when workflows are dispatched centrally.Cover centralized dispatch regressions
resolveTarget()behavior onworkflow_dispatch+aw_contextupdate_issueresolving the triggering issue without an explicitissue_numberadd_labels/remove_labelsresolving issue context from relayed dispatch metadataThis change is intended to make
update_issue,add_labels, andremove_labelsbehave consistently with existing comment delivery in centralized slash-command workflows.