Skip to content

Commit 2feeb9d

Browse files
committed
Proceed with reopen when wontfix label check fails
1 parent 52d65a7 commit 2feeb9d

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

.github/actions/file/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ export default async function () {
108108
}
109109
} else if (isRepeatedFiling(filing)) {
110110
const issue = new Issue(filing.issue)
111-
if (await isWontfixIssue(octokit, issue)) {
111+
let isWontfix = false
112+
try {
113+
isWontfix = await isWontfixIssue(octokit, issue)
114+
} catch (error) {
115+
// A failed label check shouldn't abort the run, so reopen as usual
116+
core.warning(`Could not check labels for ${filing.issue.url}; proceeding with reopen: ${error}`)
117+
}
118+
if (isWontfix) {
112119
// The developer intentionally closed this issue and labeled it 'wontfix', so leave it closed
113120
core.info(`Skipping reopen of issue labeled '${WONTFIX_LABEL}': ${filing.issue.url}`)
114121
} else {

.github/actions/file/tests/wontfixReopen.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ vi.mock('../src/closeIssue.js', () => ({closeIssue: (...args: unknown[]) => clos
99

1010
const inputs: Record<string, string> = {}
1111
const infoLines: string[] = []
12+
const warnLines: string[] = []
1213
const outputs: Record<string, string> = {}
1314
vi.mock('@actions/core', () => ({
1415
getInput: (name: string) => inputs[name] ?? '',
@@ -20,7 +21,9 @@ vi.mock('@actions/core', () => ({
2021
infoLines.push(msg)
2122
},
2223
debug: () => {},
23-
warning: () => {},
24+
warning: (msg: string) => {
25+
warnLines.push(msg)
26+
},
2427
setFailed: () => {},
2528
}))
2629

@@ -89,6 +92,7 @@ describe('file action — wontfix label', () => {
8992
beforeEach(() => {
9093
vi.clearAllMocks()
9194
infoLines.length = 0
95+
warnLines.length = 0
9296
for (const k of Object.keys(inputs)) delete inputs[k]
9397
for (const k of Object.keys(outputs)) delete outputs[k]
9498
})
@@ -117,4 +121,16 @@ describe('file action — wontfix label', () => {
117121
"Skipping reopen of issue labeled 'wontfix': https://github.com/org/repo/issues/1",
118122
)
119123
})
124+
125+
it('reopens as usual (and warns) when the label check fails', async () => {
126+
setup()
127+
// The label-check GET fails for every issue (e.g. transient API error)
128+
octokitRequest.mockRejectedValue(new Error('boom'))
129+
130+
await runFileAction()
131+
132+
// Both repeated filings should still be reopened rather than aborting the run
133+
expect(reopenIssue).toHaveBeenCalledTimes(2)
134+
expect(warnLines.join('\n')).toContain('Could not check labels for')
135+
})
120136
})

0 commit comments

Comments
 (0)