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
2 changes: 1 addition & 1 deletion actions/setup/js/assign_copilot_to_created_issues.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function main() {
const repoSlug = parts[0];
const issueNumber = parseInt(parts[1], 10);

if (isNaN(issueNumber) || issueNumber <= 0) {
if (Number.isNaN(issueNumber) || issueNumber <= 0) {
core.warning(`Invalid issue number in entry: ${entry}`);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/assign_milestone.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async function main(config = {}) {

let milestoneNumber = Number(item.milestone_number);
const milestoneTitle = item.milestone_title || null;
const hasMilestoneNumber = !isNaN(milestoneNumber) && milestoneNumber > 0;
const hasMilestoneNumber = !Number.isNaN(milestoneNumber) && milestoneNumber > 0;

// Validate that at least one of milestone_number or milestone_title is provided
if (!hasMilestoneNumber && !milestoneTitle) {
Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/assign_to_agent.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function createAssignToAgentGitHubClient(config) {
async function main(config = {}) {
// Parse configuration (replaces env vars from the old standalone step)
const maxCount = parseInt(String(config.max ?? "1"), 10);
if (isNaN(maxCount) || maxCount < 1) {
if (Number.isNaN(maxCount) || maxCount < 1) {
throw new Error(`Invalid max value: ${config.max}. Must be a positive integer`);
}
const defaultAgent = String(config.name ?? "copilot").trim();
Expand Down Expand Up @@ -299,7 +299,7 @@ async function main(config = {}) {
const issueNumber = type === "issue" ? number : null;
const pullNumber = type === "pull request" ? number : null;

if (isNaN(number) || number <= 0) {
if (Number.isNaN(number) || number <= 0) {
const error = `Invalid ${type} number: ${number}`;
core.error(error);
_allResults.push({ issue_number: issueNumber, pull_number: pullNumber, agent: agentName, owner: effectiveOwner, repo: effectiveRepo, success: false, error });
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/autofix_code_scanning_alert.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function main(config = {}) {

// Parse alert number
const alertNumber = parseInt(String(message.alert_number), 10);
if (isNaN(alertNumber) || alertNumber <= 0) {
if (Number.isNaN(alertNumber) || alertNumber <= 0) {
core.warning(`Invalid alert_number: ${message.alert_number}`);
return { success: false, error: `Invalid alert_number: ${message.alert_number}` };
}
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/check_skip_if_check_failing.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function parseListEnv(envValue) {
async function getCurrentRunCheckRunIds(owner, repo, runId) {
if (!runId) return new Set();
const numericRunId = parseInt(runId, 10);
if (isNaN(numericRunId)) return new Set();
if (Number.isNaN(numericRunId)) return new Set();
try {
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
owner,
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/check_skip_if_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function runSkipQueryGate(options) {
core.info(`Running ${checkLabel} gate for workflow: ${workflowName}`);

const threshold = parseInt(thresholdStr ?? "", 10);
if (isNaN(threshold) || threshold < 1) {
if (Number.isNaN(threshold) || threshold < 1) {
core.setFailed(`${ERR_CONFIG}: Configuration error: ${thresholdEnvVar} must be a positive integer, got "${thresholdStr}".`);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/check_stop_time.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function main() {
// Parse the stop time (format: "YYYY-MM-DD HH:MM:SS")
const stopTimeDate = new Date(stopTime);

if (isNaN(stopTimeDate.getTime())) {
if (Number.isNaN(stopTimeDate.getTime())) {
core.setFailed(`${ERR_VALIDATION}: Invalid stop-time format: ${stopTime}. Expected format: YYYY-MM-DD HH:MM:SS`);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/close_entity_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function resolveEntityNumber(config, target, item, isEntityContext) {
const targetNumber = item[config.numberField];
if (targetNumber) {
const parsed = parseInt(targetNumber, 10);
if (isNaN(parsed) || parsed <= 0) {
if (Number.isNaN(parsed) || parsed <= 0) {
return {
success: false,
message: `Invalid ${config.displayName} number specified: ${targetNumber}`,
Expand All @@ -172,7 +172,7 @@ function resolveEntityNumber(config, target, item, isEntityContext) {

if (target !== "triggering") {
const parsed = parseInt(target, 10);
if (isNaN(parsed) || parsed <= 0) {
if (Number.isNaN(parsed) || parsed <= 0) {
return {
success: false,
message: `Invalid ${config.displayName} number in target configuration: ${target}`,
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/close_issue.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async function main(config = {}) {

// Not a temporary ID - parse as integer
const issueNumber = parseInt(String(item.issue_number), 10);
if (isNaN(issueNumber)) {
if (Number.isNaN(issueNumber)) {
return { success: false, error: `Invalid issue number: ${item.issue_number}` };
}
return { success: true, entityNumber: issueNumber, owner: repoParts.owner, repo: repoParts.repo, entityRepo };
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/close_pull_request.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function main(config = {}) {
let prNumber;
if (item.pull_request_number !== undefined) {
prNumber = parseInt(String(item.pull_request_number), 10);
if (isNaN(prNumber)) {
if (Number.isNaN(prNumber)) {
return { success: false, error: `Invalid pull request number: ${item.pull_request_number}` };
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions actions/setup/js/create_code_scanning_alert.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async function main(config = {}) {

// Parse line number
const line = parseInt(securityItem.line, 10);
if (isNaN(line) || line <= 0) {
if (Number.isNaN(line) || line <= 0) {
core.warning(`Invalid line number: ${securityItem.line}`);
return {
success: false,
Expand All @@ -166,7 +166,7 @@ async function main(config = {}) {
};
}
const parsedColumn = parseInt(securityItem.column, 10);
if (isNaN(parsedColumn) || parsedColumn <= 0) {
if (Number.isNaN(parsedColumn) || parsedColumn <= 0) {
core.warning(`Invalid column number: ${securityItem.column}`);
return {
success: false,
Expand Down Expand Up @@ -260,7 +260,7 @@ async function main(config = {}) {

// Set outputs for the GitHub Action (these will be overwritten with each call)
core.setOutput("sarif_file", sarifFilePath);
core.setOutput("findings_count", validFindings.length);
core.setOutput("findings_count", String(validFindings.length));
core.setOutput("artifact_uploaded", "pending");
core.setOutput("codeql_uploaded", "pending");
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/create_code_scanning_alert.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe("create_code_scanning_alert (Handler Factory Architecture)", () => {
await handler(message, {});

expect(mockCore.setOutput).toHaveBeenCalledWith("sarif_file", sarifFile);
expect(mockCore.setOutput).toHaveBeenCalledWith("findings_count", 1);
expect(mockCore.setOutput).toHaveBeenCalledWith("findings_count", "1");
expect(mockCore.setOutput).toHaveBeenCalledWith("artifact_uploaded", "pending");
expect(mockCore.setOutput).toHaveBeenCalledWith("codeql_uploaded", "pending");
});
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/create_discussion.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async function main(config = {}) {
if (rawCloseOlderKey && !closeOlderKey) {
throw new Error(`${ERR_VALIDATION}: close-older-key "${rawCloseOlderKey}" is invalid: it must contain at least one alphanumeric character after normalization`);
}
if (isNaN(minBodyLength) || minBodyLength < 0) {
if (Number.isNaN(minBodyLength) || minBodyLength < 0) {
throw new Error(`${ERR_VALIDATION}: min_body_length must be a non-negative integer (got: ${config.min_body_length})`);
}
const includeFooter = parseBoolTemplatable(config.footer, true);
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/create_issue.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ async function main(config = {}) {
} else {
// It's a real issue number
const parsed = parseInt(withoutHash, 10);
if (!isNaN(parsed)) {
if (!Number.isNaN(parsed)) {
effectiveParentIssueNumber = parsed;
} else {
core.warning(`Invalid parent value: ${message.parent}. Expected either a valid temporary ID (format: aw_XXXXXXXXXXXX where X is a hex digit) or a numeric issue number.`);
Expand Down
8 changes: 4 additions & 4 deletions actions/setup/js/create_pr_review_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async function main(config = {}) {
// For target "*", we need an explicit PR number from the comment item
if (commentItem.pull_request_number) {
pullRequestNumber = parseInt(commentItem.pull_request_number, 10);
if (isNaN(pullRequestNumber) || pullRequestNumber <= 0) {
if (Number.isNaN(pullRequestNumber) || pullRequestNumber <= 0) {
core.warning(`Invalid pull request number specified: ${commentItem.pull_request_number}`);
return {
success: false,
Expand All @@ -192,7 +192,7 @@ async function main(config = {}) {
} else if (commentTarget && commentTarget !== "triggering") {
// Explicit PR number specified in target
pullRequestNumber = parseInt(commentTarget, 10);
if (isNaN(pullRequestNumber) || pullRequestNumber <= 0) {
if (Number.isNaN(pullRequestNumber) || pullRequestNumber <= 0) {
core.warning(`Invalid pull request number in target configuration: ${commentTarget}`);
return {
success: false,
Expand Down Expand Up @@ -256,7 +256,7 @@ async function main(config = {}) {

// Parse line numbers
const line = parseInt(commentItem.line, 10);
if (isNaN(line) || line <= 0) {
if (Number.isNaN(line) || line <= 0) {
core.warning(`Invalid line number: ${commentItem.line}`);
return {
success: false,
Expand All @@ -267,7 +267,7 @@ async function main(config = {}) {
let startLine = undefined;
if (commentItem.start_line) {
startLine = parseInt(commentItem.start_line, 10);
if (isNaN(startLine) || startLine <= 0 || startLine > line) {
if (Number.isNaN(startLine) || startLine <= 0 || startLine > line) {
core.warning(`Invalid start_line number: ${commentItem.start_line} (must be <= line: ${line})`);
return {
success: false,
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/create_project_status_update.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function formatDate(date) {
}
// Otherwise parse and format
const parsed = new Date(date);
if (isNaN(parsed.getTime())) {
if (Number.isNaN(parsed.getTime())) {
core.warning(`Invalid date "${date}", using today`);
return new Date().toISOString().split("T")[0];
}
Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/ephemerals.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function extractExpirationDate(body) {
const expirationDate = new Date(expirationISO);

// Validate the date
if (!isNaN(expirationDate.getTime())) {
if (!Number.isNaN(expirationDate.getTime())) {
return expirationDate;
}
}
Expand All @@ -83,7 +83,7 @@ function extractExpirationDate(body) {
const expirationDate = new Date(dateString);

// Validate the date
if (!isNaN(expirationDate.getTime())) {
if (!Number.isNaN(expirationDate.getTime())) {
return expirationDate;
}
}
Expand Down
4 changes: 2 additions & 2 deletions actions/setup/js/error_recovery.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function getRetryAfterMs(error) {
const retryAfter = headers["retry-after"];
if (retryAfter != null) {
const seconds = parseInt(retryAfter, 10);
if (!isNaN(seconds) && seconds > 0) {
if (!Number.isNaN(seconds) && seconds > 0) {
return seconds * 1000;
}
}
Expand All @@ -144,7 +144,7 @@ function getRetryAfterMs(error) {
const resetAt = headers["x-ratelimit-reset"];
if (resetAt != null) {
const resetTimestampMs = parseInt(resetAt, 10) * 1000;
if (!isNaN(resetTimestampMs)) {
if (!Number.isNaN(resetTimestampMs)) {
const waitMs = resetTimestampMs - Date.now();
if (waitMs > 0) {
return waitMs;
Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/generate_usage_activity_summary.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function parseFirewallLogs() {

let allowed = false;
const code = parseInt(status, 10);
if (!isNaN(code) && [200, 206, 304].includes(code)) {
if (!Number.isNaN(code) && [200, 206, 304].includes(code)) {
allowed = true;
}

Expand Down
2 changes: 1 addition & 1 deletion actions/setup/js/github_rate_limit_logger.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function appendEntry(entry) {
function parseResetTimestamp(resetHeader) {
if (!resetHeader) return null;
const seconds = parseInt(resetHeader, 10);
if (isNaN(seconds)) return null;
if (Number.isNaN(seconds)) return null;
return new Date(seconds * 1000).toISOString();
}

Expand Down
4 changes: 3 additions & 1 deletion actions/setup/js/merge_remote_agent_github_folder.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ async function main() {

// Run if executed directly (not imported)
if (require.main === module) {
main();
main().catch(err => {
coreObj.setFailed(err && err.stack ? err.stack : String(err));
});
}

module.exports = {
Expand Down
10 changes: 5 additions & 5 deletions actions/setup/js/parse_codex_log.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function extractMCPInitialization(lines) {
// Match: Found N MCP servers in configuration
const countMatch = line.match(/Found (\d+) MCP servers? in configuration/i);
if (countMatch) {
serverCount = parseInt(countMatch[1]);
serverCount = parseInt(countMatch[1], 10);
}

// Match: Connecting to MCP server: <name>
Expand Down Expand Up @@ -142,8 +142,8 @@ function extractCodexErrorMessages(lines) {
// Match: Reconnecting... N/M (error message) - reconnect attempts with error details
const reconnectMatch = line.match(/^Reconnecting\.\.\.\s+(\d+)\/(\d+)\s*\((.+)\)$/);
if (reconnectMatch) {
const attempt = parseInt(reconnectMatch[1]);
const total = parseInt(reconnectMatch[2]);
const attempt = parseInt(reconnectMatch[1], 10);
const total = parseInt(reconnectMatch[2], 10);
if (attempt > reconnectCount) reconnectCount = attempt;
if (total > maxReconnects) maxReconnects = total;
messages.add(reconnectMatch[3].trim());
Expand Down Expand Up @@ -795,15 +795,15 @@ function parseCodexLog(logContent) {
// TokenCount(TokenCountEvent { ... total_tokens: 13281 ...
const tokenCountMatches = logContent.matchAll(/total_tokens:\s*(\d+)/g);
for (const match of tokenCountMatches) {
const tokens = parseInt(match[1]);
const tokens = parseInt(match[1], 10);
totalTokens = Math.max(totalTokens, tokens); // Use the highest value (final total)
}

// Also check for "tokens used\n<number>" at the end (number may have commas)
const finalTokensMatch = logContent.match(/tokens used\n([\d,]+)/);
if (finalTokensMatch) {
// Remove commas before parsing
totalTokens = parseInt(finalTokensMatch[1].replace(/,/g, ""));
totalTokens = parseInt(finalTokensMatch[1].replace(/,/g, ""), 10);
}

if (totalTokens > 0) {
Expand Down
5 changes: 4 additions & 1 deletion actions/setup/js/parse_mcp_gateway_log.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,5 +1131,8 @@ if (typeof module !== "undefined" && module.exports) {

// Run main if called directly
if (require.main === module) {
main();
main().catch(err => {
console.error(err && err.stack ? err.stack : String(err));
process.exitCode = 1;
});
}
37 changes: 37 additions & 0 deletions actions/setup/js/parse_mcp_gateway_log.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,43 @@ Some content here.`;
fs.rmSync(tmpDir, { recursive: true, force: true });
}
});

test("calls setFailed when an unexpected error is thrown inside main", async () => {
const originalExistsSync = fs.existsSync;
const originalReadFileSync = fs.readFileSync;

const mockCore = {
info: vi.fn(),
debug: vi.fn(),
startGroup: vi.fn(),
endGroup: vi.fn(),
notice: vi.fn(),
warning: vi.fn(),
error: vi.fn(),
setFailed: vi.fn(),
exportVariable: vi.fn(),
setOutput: vi.fn(),
summary: {
addRaw: vi.fn().mockReturnThis(),
addDetails: vi.fn().mockReturnThis(),
write: vi.fn().mockRejectedValue(new Error("summary write failure")),
},
};

fs.existsSync = vi.fn(() => false);
fs.readFileSync = vi.fn((p, enc) => originalReadFileSync(p, enc));
global.core = mockCore;

try {
const { main } = require("./parse_mcp_gateway_log.cjs");
await main();
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("summary write failure"));
} finally {
fs.existsSync = originalExistsSync;
fs.readFileSync = originalReadFileSync;
delete global.core;
}
});
});

describe("printAllGatewayFiles", () => {
Expand Down
5 changes: 4 additions & 1 deletion actions/setup/js/parse_mcp_scripts_logs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -412,5 +412,8 @@ if (typeof module !== "undefined" && module.exports) {

// Run main if called directly
if (require.main === module) {
main();
main().catch(err => {
console.error(err && err.stack ? err.stack : String(err));
process.exitCode = 1;
});
}
5 changes: 4 additions & 1 deletion actions/setup/js/parse_token_usage.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,8 @@ if (typeof module !== "undefined" && module.exports) {

// Run main if called directly
if (require.main === module) {
main();
main().catch(err => {
console.error(err && err.stack ? err.stack : String(err));
process.exitCode = 1;
});
}
Loading
Loading