-
Notifications
You must be signed in to change notification settings - Fork 1
fix: guard workflow source context automation #1947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1023,6 +1023,10 @@ function resolveExplicitNonIssueWorkflowSourceContext(pr = {}) { | |
| }; | ||
| } | ||
|
|
||
| function resolveNonIssueWorkflowSourceContextForBodySync(pr = {}, issueNumber = null) { | ||
| return issueNumber ? null : resolveExplicitNonIssueWorkflowSourceContext(pr); | ||
| } | ||
|
|
||
| async function resolveSourceContextRepairComment({ | ||
| github, | ||
| owner, | ||
|
|
@@ -1356,7 +1360,9 @@ async function run({github: rawGithub, context, core, inputs}) { | |
| return; | ||
| } | ||
|
|
||
| const explicitNonIssueSourceContext = resolveExplicitNonIssueWorkflowSourceContext(pr); | ||
| const issueNumber = extractIssueNumberFromPull(pr); | ||
| const sourceContext = resolvePrSourceContext(pr); | ||
| const explicitNonIssueSourceContext = resolveNonIssueWorkflowSourceContextForBodySync(pr, issueNumber); | ||
| if (explicitNonIssueSourceContext) { | ||
| core.info( | ||
| `PR #${pr.number} has explicit non-issue workflow source context (${formatSourceContextForLog(explicitNonIssueSourceContext)}); skipping issue-sourced body sync.`, | ||
|
|
@@ -1382,8 +1388,6 @@ async function run({github: rawGithub, context, core, inputs}) { | |
| return; | ||
| } | ||
|
|
||
| const issueNumber = extractIssueNumberFromPull(pr); | ||
| const sourceContext = resolvePrSourceContext(pr); | ||
| if (!issueNumber) { | ||
| if (sourceContext.isValid && !sourceContext.requiresIssue) { | ||
| core.info( | ||
|
|
@@ -1454,6 +1458,25 @@ async function run({github: rawGithub, context, core, inputs}) { | |
| return; | ||
| } | ||
|
|
||
| try { | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner, | ||
| repo, | ||
| issue_number: pr.number, | ||
| }); | ||
| await resolveSourceContextRepairComment({ | ||
| github, | ||
| owner, | ||
| repo, | ||
| prNumber: pr.number, | ||
| comments, | ||
| sourceContext, | ||
| core, | ||
| }); | ||
|
Comment on lines
+1471
to
+1475
|
||
| } catch (error) { | ||
| core.warning(`Failed to resolve workflow source repair comment: ${error.message}`); | ||
| } | ||
|
|
||
| core.info(`Fetching content from issue #${issueNumber} for PR #${pr.number}`); | ||
| const issueResponse = await withRetries( | ||
| () => github.rest.issues.get({owner, repo, issue_number: issueNumber}), | ||
|
|
@@ -1629,6 +1652,7 @@ module.exports = { | |
| buildSourceContextRepairCommentBody, | ||
| buildSourceContextResolvedCommentBody, | ||
| resolveExplicitNonIssueWorkflowSourceContext, | ||
| resolveNonIssueWorkflowSourceContextForBodySync, | ||
| resolveSourceContextRepairComment, | ||
| isCampaignIssue, | ||
| buildStatusBlock, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new gate now discards explicit non-issue workflow markers whenever
issueNumberis truthy, but inrun()that value comes fromextractIssueNumberFromPull(from the keepalive script), which accepts broad matches like#123in titles/branches. That means a non-issue PR with<!-- workflow-source:local_request -->can now be misclassified as issue-sourced just because its title contains an incidental#N, and the body-sync flow will fetch and apply content from an unrelated issue. Please key this decision off a stricter issue signal (for example the source-context resolver’s issue determination) before suppressing non-issue context.Useful? React with 👍 / 👎.