MCPcopy Create free account
hub / github.com/github/gh-aw / createFallbackIssue

Function createFallbackIssue

actions/setup/js/create_pull_request.cjs:368–401  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

366 * @returns {Promise<any>}
367 */
368async 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.

Callers 1

mainFunction · 0.85

Calls 2

withRetryFunction · 0.85
getErrorMessageFunction · 0.70

Tested by

no test coverage detected