-
Notifications
You must be signed in to change notification settings - Fork 529
Fix temporary ID substitution in safe-output comments #57955
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 |
|---|---|---|
|
|
@@ -1166,7 +1166,21 @@ async function processMessages(messageHandlers, messages, onItemCreated = null) | |
| // Check if this output was created with unresolved temporary IDs | ||
| // For create_issue, create_discussion, add_comment - check if body has unresolved IDs | ||
|
|
||
| // Handle add_comment which returns an array of comments | ||
| // Handle the current add_comment result shape. | ||
| if (messageType === "add_comment" && result?.commentId && result?.repo) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actions/setup/js/safe_output_handler_manager.cjs:L1170: shrink: two near-duplicate add_comment branches for object and array results. One normalized branch or helper handles both shapes once. |
||
| const contentToCheck = getContentToCheck(messageType, message, result); | ||
| if (contentToCheck && hasUnresolvedTemporaryIds(contentToCheck, temporaryIdMap, artifactUrlMap)) { | ||
| core.info(`Comment ${result.commentId} on ${result.repo}#${result.itemNumber} was created with unresolved temporary IDs - tracking for update`); | ||
| outputsWithUnresolvedIds.push({ | ||
| type: messageType, | ||
| message, | ||
| result, | ||
| originalTempIdMapSize: tempIdMapSizeBefore, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| // Handle the legacy add_comment result shape. | ||
| if (messageType === "add_comment" && Array.isArray(result)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that |
||
| const contentToCheck = getContentToCheck(messageType, message, result); | ||
| if (contentToCheck && hasUnresolvedTemporaryIds(contentToCheck, temporaryIdMap, artifactUrlMap)) { | ||
|
|
@@ -1177,12 +1191,7 @@ async function processMessages(messageHandlers, messages, onItemCreated = null) | |
| outputsWithUnresolvedIds.push({ | ||
| type: messageType, | ||
| message: message, | ||
| result: { | ||
| commentId: comment._tracking.commentId, | ||
| itemNumber: comment._tracking.itemNumber, | ||
| repo: comment._tracking.repo, | ||
| isDiscussion: comment._tracking.isDiscussion, | ||
| }, | ||
| result: { ...comment._tracking, ...(comment.body ? { body: comment.body } : {}) }, | ||
| originalTempIdMapSize: tempIdMapSizeBefore, | ||
| }); | ||
| } | ||
|
|
@@ -1384,7 +1393,7 @@ function getContentToCheck(messageType, message, result) { | |
| case "create_discussion": | ||
| return message.body || ""; | ||
| case "add_comment": | ||
| return message.body || ""; | ||
| return result?.body || message.body || ""; | ||
| case "comment_memory": | ||
| return result?.managedBody || message.body || ""; | ||
| case "create_pull_request": | ||
|
|
@@ -2026,4 +2035,5 @@ module.exports = { | |
| partitionFailureResults, | ||
| computeSafeOutputsStatus, | ||
| setSafeOutputsStatusOutputs, | ||
| processSyntheticUpdates, | ||
| }; | ||
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.
@copilot review all other safe outputs for different shapes
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.
Reviewed the safe-output result conventions and updated add_comment tracking to use the current object body while preserving its metadata, with legacy array support retaining tracking metadata and optional body. Regression coverage now exercises the synthetic update request. Changes are in 5a6bff2 and 6d81653.