Skip to content
Merged
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
21 changes: 19 additions & 2 deletions actions/setup/js/create_pull_request.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs");
/** @type {string} Safe output type handled by this module */
const HANDLER_TYPE = "create_pull_request";

/** @type {string} Label always added to fallback issues so the triage system can find them */
const MANAGED_FALLBACK_ISSUE_LABEL = "agentic-workflows";

/**
* Merges the required fallback label with any workflow-configured labels,
* deduplicating and filtering empty values.
* @param {string[]} [labels]
* @returns {string[]}
*/
function mergeFallbackIssueLabels(labels = []) {
const normalizedLabels = labels
.filter(label => !!label)
.map(label => String(label).trim())
.filter(label => label);
return [...new Set([MANAGED_FALLBACK_ISSUE_LABEL, ...normalizedLabels])];
}
Comment on lines +40 to +46
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mergeFallbackIssueLabels function is a pure, non-trivial helper that implements deduplication, filtering of empty/whitespace values, and prepending of the required label. However, it is not exported in module.exports and has no corresponding tests in create_pull_request.test.cjs, even though the test file already exercises enforcePullRequestLimits directly (which is exported).

To keep with this convention, mergeFallbackIssueLabels should be added to module.exports and tested with cases such as:

  • Default/empty input produces ["agentic-workflows"]
  • Existing labels are preserved alongside "agentic-workflows"
  • Duplicate "agentic-workflows" entries are deduplicated
  • Empty/whitespace labels are filtered out
  • Non-string label values are coerced and trimmed correctly

Copilot uses AI. Check for mistakes.

/**
* Maximum limits for pull request parameters to prevent resource exhaustion.
* These limits align with GitHub's API constraints and security best practices.
Expand Down Expand Up @@ -723,7 +740,7 @@ ${patchPreview}`;
repo: repoParts.repo,
title: title,
body: fallbackBody,
labels: labels,
labels: mergeFallbackIssueLabels(labels),
});

core.info(`Created fallback issue #${issue.number}: ${issue.html_url}`);
Expand Down Expand Up @@ -985,7 +1002,7 @@ ${patchPreview}`;
repo: repoParts.repo,
title: title,
body: fallbackBody,
labels: labels,
labels: mergeFallbackIssueLabels(labels),
});

core.info(`Created fallback issue #${issue.number}: ${issue.html_url}`);
Expand Down
Loading