-
Notifications
You must be signed in to change notification settings - Fork 251
Refactor locked issue error handling into shared helper #15998
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 |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| const { loadAgentOutput } = require("./load_agent_output.cjs"); | ||
| const { getRunSuccessMessage, getRunFailureMessage, getDetectionFailureMessage } = require("./messages_run_status.cjs"); | ||
| const { getMessages } = require("./messages_core.cjs"); | ||
| const { getErrorMessage } = require("./error_helpers.cjs"); | ||
| const { getErrorMessage, isLockedError } = require("./error_helpers.cjs"); | ||
| const { sanitizeContent } = require("./sanitize_content.cjs"); | ||
|
|
||
| /** | ||
|
|
@@ -246,7 +246,14 @@ async function main() { | |
| if (response?.data?.html_url) core.info(`Comment URL: ${response.data.html_url}`); | ||
| return; | ||
| } catch (error) { | ||
| // Don't fail the workflow if we can't create the comment | ||
| // Check if the error is due to a locked issue/PR/discussion | ||
| if (isLockedError(error)) { | ||
| // Silently ignore locked resource errors - just log for debugging | ||
| core.info(`Cannot create append-only comment: resource is locked (this is expected and not an error)`); | ||
| return; | ||
| } | ||
|
|
||
| // Don't fail the workflow if we can't create the comment (for other errors) | ||
| core.warning(`Failed to create append-only comment: ${getErrorMessage(error)}`); | ||
| return; | ||
| } | ||
|
|
@@ -300,7 +307,14 @@ async function main() { | |
| core.info(`Comment URL: ${response.data.html_url}`); | ||
| } | ||
| } catch (error) { | ||
| // Don't fail the workflow if we can't update the comment | ||
| // Check if the error is due to a locked issue/PR/discussion | ||
| if (isLockedError(error)) { | ||
| // Silently ignore locked resource errors - just log for debugging | ||
| core.info(`Cannot update comment: resource is locked (this is expected and not an error)`); | ||
| return; | ||
| } | ||
|
Comment on lines
249
to
315
|
||
|
|
||
| // Don't fail the workflow if we can't update the comment (for other errors) | ||
| core.warning(`Failed to update comment: ${getErrorMessage(error)}`); | ||
| } | ||
| } | ||
|
|
||
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.
Test description and expectation are contradictory. The test is named "should return false for 403 error with only partial match" and the comment on line 88 states "Contains 'unlocked' which includes 'locked' substring", suggesting this should return false (not a locked error). However, the expectation on line 89 is
expect(isLockedError(error)).toBe(true), which expects true.The message "This issue has been unlocked" contains "locked" as a substring but indicates the resource is NOT locked. The function should return false for this case to avoid false positives. Change the expectation to
toBe(false)to match the test description.