Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions actions/setup/js/add_reaction.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ async function main() {
const is403Error = error && typeof error === "object" && "status" in error && error.status === 403;
const hasLockedMessage = errorMessage && (errorMessage.includes("locked") || errorMessage.includes("Lock conversation"));

// Only ignore the error if it's a 403 AND mentions locked, or if the message mentions locked
if ((is403Error && hasLockedMessage) || (!is403Error && hasLockedMessage)) {
// Only ignore the error if it's BOTH a 403 status code AND mentions locked
if (is403Error && hasLockedMessage) {
// Silently ignore locked resource errors - just log for debugging
core.info(`Cannot add reaction: resource is locked (this is expected and not an error)`);
return;
Expand Down
12 changes: 7 additions & 5 deletions actions/setup/js/add_reaction.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,16 @@ describe("add_reaction", () => {
expect(mockCore.setFailed).not.toHaveBeenCalled();
});

it("should silently ignore locked issue errors (message contains 'locked')", async () => {
mockGithub.request.mockRejectedValueOnce(new Error("Lock conversation is enabled"));
it("should fail for errors with 'locked' message but non-403 status", async () => {
// Errors mentioning "locked" should only be ignored if they have 403 status
const lockedError = new Error("Lock conversation is enabled");
lockedError.status = 500; // Not 403
mockGithub.request.mockRejectedValueOnce(lockedError);

await runScript();

expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("resource is locked"));
expect(mockCore.error).not.toHaveBeenCalled();
expect(mockCore.setFailed).not.toHaveBeenCalled();
expect(mockCore.error).toHaveBeenCalledWith(expect.stringContaining("Failed to add reaction"));
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Failed to add reaction"));
});

it("should fail for 403 errors that don't mention locked", async () => {
Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/add_reaction_and_edit_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ async function main() {
const is403Error = error && typeof error === "object" && "status" in error && error.status === 403;
const hasLockedMessage = errorMessage && (errorMessage.includes("locked") || errorMessage.includes("Lock conversation"));

// Only ignore the error if it's a 403 AND mentions locked, or if the message mentions locked
if ((is403Error && hasLockedMessage) || (!is403Error && hasLockedMessage)) {
// Only ignore the error if it's BOTH a 403 status code AND mentions locked
if (is403Error && hasLockedMessage) {
// Silently ignore locked resource errors - just log for debugging
core.info(`Cannot add reaction: resource is locked (this is expected and not an error)`);
return;
Expand Down
12 changes: 7 additions & 5 deletions actions/setup/js/add_reaction_and_edit_comment.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,17 @@ const mockCore = {
expect(mockCore.error).not.toHaveBeenCalled(),
expect(mockCore.setFailed).not.toHaveBeenCalled());
}),
it("should silently ignore locked issue errors (message contains 'locked')", async () => {
it("should fail for errors with 'locked' message but non-403 status", async () => {
// Errors mentioning "locked" should only be ignored if they have 403 status
const lockedError = new Error("Lock conversation is enabled");
lockedError.status = 500; // Not 403
((process.env.GH_AW_REACTION = "eyes"),
(global.context.eventName = "issues"),
(global.context.payload = { issue: { number: 123 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
mockGithub.request.mockRejectedValueOnce(new Error("Lock conversation is enabled")),
mockGithub.request.mockRejectedValueOnce(lockedError),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("resource is locked")),
expect(mockCore.error).not.toHaveBeenCalled(),
expect(mockCore.setFailed).not.toHaveBeenCalled());
expect(mockCore.error).toHaveBeenCalledWith(expect.stringContaining("Failed to process reaction")),
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Failed to process reaction")));
}),
it("should fail for 403 errors that don't mention locked", async () => {
const forbiddenError = new Error("Forbidden: insufficient permissions");
Expand Down