* Creates a fallback GitHub issue, retrying on rate-limit and other transient errors * (with exponential back-off) and retrying without assignees if the API rejects them. * This ensures fallback issue creation remains reliable even if an assignee username * is invalid, the repository does not hav
(githubClient, repoParts, title, body, labels, assignees)
| 366 | * @returns {Promise<any>} |
| 367 | */ |
| 368 | async function createFallbackIssue(githubClient, repoParts, title, body, labels, assignees) { |
| 369 | const payload = { |
| 370 | owner: repoParts.owner, |
| 371 | repo: repoParts.repo, |
| 372 | title, |
| 373 | body, |
| 374 | labels, |
| 375 | ...(assignees && assignees.length > 0 && { assignees }), |
| 376 | }; |
| 377 | |
| 378 | return withRetry( |
| 379 | async () => { |
| 380 | try { |
| 381 | return await githubClient.rest.issues.create(payload); |
| 382 | } catch (error) { |
| 383 | const status = typeof error === "object" && error !== null && "status" in error ? error.status : undefined; |
| 384 | const message = getErrorMessage(error).toLowerCase(); |
| 385 | const isAssigneeError = status === 422 && (message.includes("assignee") || message.includes("assignees") || message.includes("unprocessable")); |
| 386 | if (isAssigneeError && payload.assignees && payload.assignees.length > 0) { |
| 387 | const removedAssignees = payload.assignees.join(", "); |
| 388 | core.warning(`Fallback issue creation failed due to assignee error, retrying without assignees: ${getErrorMessage(error)}`); |
| 389 | // Mutate payload in-place so that any subsequent withRetry attempts also |
| 390 | // omit assignees and do not re-trigger the same 422 path. |
| 391 | delete payload.assignees; |
| 392 | payload.body = `${payload.body}\n\n> [!NOTE]\n> Assignees (${removedAssignees}) could not be set on this issue due to an API error.`; |
| 393 | return await githubClient.rest.issues.create(payload); |
| 394 | } |
| 395 | throw error; |
| 396 | } |
| 397 | }, |
| 398 | RATE_LIMIT_RETRY_CONFIG, |
| 399 | `create fallback issue in ${repoParts.owner}/${repoParts.repo}` |
| 400 | ); |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Maximum limits for pull request parameters to prevent resource exhaustion. |
no test coverage detected