From 6599b4813b7dcef22ea7039e01c8e46e6b4f6c04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 21:02:44 +0000 Subject: [PATCH 01/12] Initial plan From 4389015762f95f4074765b770b6bc1fc36a0c418 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 21:07:40 +0000 Subject: [PATCH 02/12] Initial plan for ACTIONS_ORCHESTRATION_ID user-agent support Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- package-lock.json | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93edb739d..bb9625216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -134,6 +134,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -1279,6 +1280,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", + "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -1762,6 +1764,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -1955,6 +1958,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2312,6 +2316,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -3092,6 +3097,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -4577,6 +4583,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, + "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -6197,6 +6204,7 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -7079,6 +7087,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7438,6 +7447,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, + "peer": true, "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -8313,6 +8323,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", + "peer": true, "requires": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -8723,6 +8734,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, + "peer": true, "requires": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -8831,7 +8843,8 @@ "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", - "dev": true + "dev": true, + "peer": true }, "acorn-jsx": { "version": "5.3.2", @@ -9089,6 +9102,7 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, + "peer": true, "requires": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -9646,6 +9660,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, + "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -10682,6 +10697,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, + "peer": true, "requires": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -11911,7 +11927,8 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", - "dev": true + "dev": true, + "peer": true }, "prettier-linter-helpers": { "version": "1.0.0", @@ -12521,7 +12538,8 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", - "dev": true + "dev": true, + "peer": true }, "unbox-primitive": { "version": "1.0.2", From d053ab3e3cff13f66d8d34f16db123ed8c7d76b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 21:10:26 +0000 Subject: [PATCH 03/12] Add ACTIONS_ORCHESTRATION_ID to user-agent string Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- __test__/orchestration-id.test.ts | 73 +++++++++++++++++++++++++++++++ dist/index.js | 21 ++++++++- src/main.ts | 25 ++++++++++- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 __test__/orchestration-id.test.ts diff --git a/__test__/orchestration-id.test.ts b/__test__/orchestration-id.test.ts new file mode 100644 index 000000000..a8c596373 --- /dev/null +++ b/__test__/orchestration-id.test.ts @@ -0,0 +1,73 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +describe('getUserAgentWithOrchestrationId', () => { + let originalEnv: NodeJS.ProcessEnv + + beforeEach(() => { + originalEnv = {...process.env} + }) + + afterEach(() => { + process.env = originalEnv + }) + + // Since getUserAgentWithOrchestrationId is not exported, we'll test it indirectly + // by mocking the getInput and testing the behavior through the main function integration + // For now, we'll create simple unit tests that verify the logic + + test('appends orchestration ID when ACTIONS_ORCHESTRATION_ID is set', () => { + const baseUserAgent = 'actions/github-script' + const orchestrationId = 'test-orchestration-123' + process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId + + // Simulate the logic from getUserAgentWithOrchestrationId + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const result = `${baseUserAgent} orchestration-id/${sanitized}` + + expect(result).toBe('actions/github-script orchestration-id/test-orchestration-123') + }) + + test('sanitizes orchestration ID by removing special characters', () => { + const baseUserAgent = 'actions/github-script' + const orchestrationId = 'test@orchestration#123!abc$xyz' + + // Simulate the logic from getUserAgentWithOrchestrationId + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const result = `${baseUserAgent} orchestration-id/${sanitized}` + + expect(result).toBe('actions/github-script orchestration-id/testorchestration123abcxyz') + }) + + test('preserves dots and hyphens in orchestration ID', () => { + const baseUserAgent = 'actions/github-script' + const orchestrationId = 'test.orchestration-123' + + // Simulate the logic from getUserAgentWithOrchestrationId + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const result = `${baseUserAgent} orchestration-id/${sanitized}` + + expect(result).toBe('actions/github-script orchestration-id/test.orchestration-123') + }) + + test('does not append orchestration ID when ACTIONS_ORCHESTRATION_ID is not set', () => { + const baseUserAgent = 'actions/github-script' + delete process.env['ACTIONS_ORCHESTRATION_ID'] + + // Simulate the logic from getUserAgentWithOrchestrationId + const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID'] + const result = orchestrationId ? `${baseUserAgent} orchestration-id/${orchestrationId}` : baseUserAgent + + expect(result).toBe('actions/github-script') + }) + + test('does not append orchestration ID when it becomes empty after sanitization', () => { + const baseUserAgent = 'actions/github-script' + const orchestrationId = '@#$%^&*()' + + // Simulate the logic from getUserAgentWithOrchestrationId + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const result = sanitized ? `${baseUserAgent} orchestration-id/${sanitized}` : baseUserAgent + + expect(result).toBe('actions/github-script') + }) +}) diff --git a/dist/index.js b/dist/index.js index bb06b77b9..4138a02fb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36258,6 +36258,23 @@ const wrapRequire = new Proxy(require, { process.on('unhandledRejection', handleError); main().catch(handleError); +/** + * Gets the user agent string with orchestration ID appended if available + * @param userAgent The base user agent string + * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set + */ +function getUserAgentWithOrchestrationId(userAgent) { + const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID']; + if (!orchestrationId) { + return userAgent; + } + // Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, ''); + if (!sanitized) { + return userAgent; + } + return `${userAgent} orchestration-id/${sanitized}`; +} async function main() { const token = core.getInput('github-token', { required: true }); const debug = core.getBooleanInput('debug'); @@ -36267,9 +36284,11 @@ async function main() { const retries = parseInt(core.getInput('retries')); const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes')); const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults); + const baseUserAgent = userAgent || 'actions/github-script'; + const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent); const opts = { log: debug ? console : undefined, - userAgent: userAgent || undefined, + userAgent: finalUserAgent, previews: previews ? previews.split(',') : undefined, retry: retryOpts, request: requestOpts diff --git a/src/main.ts b/src/main.ts index baa2933dc..bcf074009 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,6 +23,26 @@ type Options = { request?: RequestRequestOptions } +/** + * Gets the user agent string with orchestration ID appended if available + * @param userAgent The base user agent string + * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set + */ +function getUserAgentWithOrchestrationId(userAgent: string): string { + const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID'] + if (!orchestrationId) { + return userAgent + } + + // Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + if (!sanitized) { + return userAgent + } + + return `${userAgent} orchestration-id/${sanitized}` +} + async function main(): Promise { const token = core.getInput('github-token', {required: true}) const debug = core.getBooleanInput('debug') @@ -39,9 +59,12 @@ async function main(): Promise { defaultGitHubOptions ) + const baseUserAgent = userAgent || 'actions/github-script' + const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent) + const opts: Options = { log: debug ? console : undefined, - userAgent: userAgent || undefined, + userAgent: finalUserAgent, previews: previews ? previews.split(',') : undefined, retry: retryOpts, request: requestOpts From baada7bb397ee70e3017ba0d042ebed55c8543b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 21:15:37 +0000 Subject: [PATCH 04/12] Apply prettier formatting to test file Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- __test__/orchestration-id.test.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/__test__/orchestration-id.test.ts b/__test__/orchestration-id.test.ts index a8c596373..c904c1d64 100644 --- a/__test__/orchestration-id.test.ts +++ b/__test__/orchestration-id.test.ts @@ -24,7 +24,9 @@ describe('getUserAgentWithOrchestrationId', () => { const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') const result = `${baseUserAgent} orchestration-id/${sanitized}` - expect(result).toBe('actions/github-script orchestration-id/test-orchestration-123') + expect(result).toBe( + 'actions/github-script orchestration-id/test-orchestration-123' + ) }) test('sanitizes orchestration ID by removing special characters', () => { @@ -35,7 +37,9 @@ describe('getUserAgentWithOrchestrationId', () => { const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') const result = `${baseUserAgent} orchestration-id/${sanitized}` - expect(result).toBe('actions/github-script orchestration-id/testorchestration123abcxyz') + expect(result).toBe( + 'actions/github-script orchestration-id/testorchestration123abcxyz' + ) }) test('preserves dots and hyphens in orchestration ID', () => { @@ -46,7 +50,9 @@ describe('getUserAgentWithOrchestrationId', () => { const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') const result = `${baseUserAgent} orchestration-id/${sanitized}` - expect(result).toBe('actions/github-script orchestration-id/test.orchestration-123') + expect(result).toBe( + 'actions/github-script orchestration-id/test.orchestration-123' + ) }) test('does not append orchestration ID when ACTIONS_ORCHESTRATION_ID is not set', () => { @@ -55,7 +61,9 @@ describe('getUserAgentWithOrchestrationId', () => { // Simulate the logic from getUserAgentWithOrchestrationId const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID'] - const result = orchestrationId ? `${baseUserAgent} orchestration-id/${orchestrationId}` : baseUserAgent + const result = orchestrationId + ? `${baseUserAgent} orchestration-id/${orchestrationId}` + : baseUserAgent expect(result).toBe('actions/github-script') }) @@ -66,7 +74,9 @@ describe('getUserAgentWithOrchestrationId', () => { // Simulate the logic from getUserAgentWithOrchestrationId const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') - const result = sanitized ? `${baseUserAgent} orchestration-id/${sanitized}` : baseUserAgent + const result = sanitized + ? `${baseUserAgent} orchestration-id/${sanitized}` + : baseUserAgent expect(result).toBe('actions/github-script') }) From f80dad6b51802013cabd11375d6043da2278a627 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 21:27:04 +0000 Subject: [PATCH 05/12] Add underscore to valid orchestration ID characters Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- __test__/orchestration-id.test.ts | 14 +++++++------- dist/index.js | 4 ++-- src/main.ts | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/__test__/orchestration-id.test.ts b/__test__/orchestration-id.test.ts index c904c1d64..5105c7f0d 100644 --- a/__test__/orchestration-id.test.ts +++ b/__test__/orchestration-id.test.ts @@ -21,7 +21,7 @@ describe('getUserAgentWithOrchestrationId', () => { process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') const result = `${baseUserAgent} orchestration-id/${sanitized}` expect(result).toBe( @@ -34,7 +34,7 @@ describe('getUserAgentWithOrchestrationId', () => { const orchestrationId = 'test@orchestration#123!abc$xyz' // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') const result = `${baseUserAgent} orchestration-id/${sanitized}` expect(result).toBe( @@ -42,16 +42,16 @@ describe('getUserAgentWithOrchestrationId', () => { ) }) - test('preserves dots and hyphens in orchestration ID', () => { + test('preserves dots, hyphens, and underscores in orchestration ID', () => { const baseUserAgent = 'actions/github-script' - const orchestrationId = 'test.orchestration-123' + const orchestrationId = 'test.orchestration-123_abc' // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') const result = `${baseUserAgent} orchestration-id/${sanitized}` expect(result).toBe( - 'actions/github-script orchestration-id/test.orchestration-123' + 'actions/github-script orchestration-id/test.orchestration-123_abc' ) }) @@ -73,7 +73,7 @@ describe('getUserAgentWithOrchestrationId', () => { const orchestrationId = '@#$%^&*()' // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') const result = sanitized ? `${baseUserAgent} orchestration-id/${sanitized}` : baseUserAgent diff --git a/dist/index.js b/dist/index.js index 4138a02fb..a133e5303 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36268,8 +36268,8 @@ function getUserAgentWithOrchestrationId(userAgent) { if (!orchestrationId) { return userAgent; } - // Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, ''); + // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, ''); if (!sanitized) { return userAgent; } diff --git a/src/main.ts b/src/main.ts index bcf074009..3b32fc9a8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,8 +34,8 @@ function getUserAgentWithOrchestrationId(userAgent: string): string { return userAgent } - // Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') + // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') if (!sanitized) { return userAgent } From 728b23b52d526d9458c7382968b467ea06ed02f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:22:39 +0000 Subject: [PATCH 06/12] Remove orchestration-id test file Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- __test__/orchestration-id.test.ts | 83 ------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 __test__/orchestration-id.test.ts diff --git a/__test__/orchestration-id.test.ts b/__test__/orchestration-id.test.ts deleted file mode 100644 index 5105c7f0d..000000000 --- a/__test__/orchestration-id.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ - -describe('getUserAgentWithOrchestrationId', () => { - let originalEnv: NodeJS.ProcessEnv - - beforeEach(() => { - originalEnv = {...process.env} - }) - - afterEach(() => { - process.env = originalEnv - }) - - // Since getUserAgentWithOrchestrationId is not exported, we'll test it indirectly - // by mocking the getInput and testing the behavior through the main function integration - // For now, we'll create simple unit tests that verify the logic - - test('appends orchestration ID when ACTIONS_ORCHESTRATION_ID is set', () => { - const baseUserAgent = 'actions/github-script' - const orchestrationId = 'test-orchestration-123' - process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId - - // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') - const result = `${baseUserAgent} orchestration-id/${sanitized}` - - expect(result).toBe( - 'actions/github-script orchestration-id/test-orchestration-123' - ) - }) - - test('sanitizes orchestration ID by removing special characters', () => { - const baseUserAgent = 'actions/github-script' - const orchestrationId = 'test@orchestration#123!abc$xyz' - - // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') - const result = `${baseUserAgent} orchestration-id/${sanitized}` - - expect(result).toBe( - 'actions/github-script orchestration-id/testorchestration123abcxyz' - ) - }) - - test('preserves dots, hyphens, and underscores in orchestration ID', () => { - const baseUserAgent = 'actions/github-script' - const orchestrationId = 'test.orchestration-123_abc' - - // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') - const result = `${baseUserAgent} orchestration-id/${sanitized}` - - expect(result).toBe( - 'actions/github-script orchestration-id/test.orchestration-123_abc' - ) - }) - - test('does not append orchestration ID when ACTIONS_ORCHESTRATION_ID is not set', () => { - const baseUserAgent = 'actions/github-script' - delete process.env['ACTIONS_ORCHESTRATION_ID'] - - // Simulate the logic from getUserAgentWithOrchestrationId - const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID'] - const result = orchestrationId - ? `${baseUserAgent} orchestration-id/${orchestrationId}` - : baseUserAgent - - expect(result).toBe('actions/github-script') - }) - - test('does not append orchestration ID when it becomes empty after sanitization', () => { - const baseUserAgent = 'actions/github-script' - const orchestrationId = '@#$%^&*()' - - // Simulate the logic from getUserAgentWithOrchestrationId - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') - const result = sanitized - ? `${baseUserAgent} orchestration-id/${sanitized}` - : baseUserAgent - - expect(result).toBe('actions/github-script') - }) -}) From 8a9be954248650e910f34f59f397f9a953594362 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:30:38 +0000 Subject: [PATCH 07/12] Move helper method to end of file and revert package-lock.json changes Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- dist/index.js | 34 +++++++++++++++++----------------- package-lock.json | 24 +++--------------------- src/main.ts | 40 ++++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 58 deletions(-) diff --git a/dist/index.js b/dist/index.js index a133e5303..156802804 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36258,23 +36258,6 @@ const wrapRequire = new Proxy(require, { process.on('unhandledRejection', handleError); main().catch(handleError); -/** - * Gets the user agent string with orchestration ID appended if available - * @param userAgent The base user agent string - * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set - */ -function getUserAgentWithOrchestrationId(userAgent) { - const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID']; - if (!orchestrationId) { - return userAgent; - } - // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, ''); - if (!sanitized) { - return userAgent; - } - return `${userAgent} orchestration-id/${sanitized}`; -} async function main() { const token = core.getInput('github-token', { required: true }); const debug = core.getBooleanInput('debug'); @@ -36332,6 +36315,23 @@ function handleError(err) { console.error(err); core.setFailed(`Unhandled error: ${err}`); } +/** + * Gets the user agent string with orchestration ID appended if available + * @param userAgent The base user agent string + * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set + */ +function getUserAgentWithOrchestrationId(userAgent) { + const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID']; + if (!orchestrationId) { + return userAgent; + } + // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, ''); + if (!sanitized) { + return userAgent; + } + return `${userAgent} orchestration-id/${sanitized}`; +} })(); diff --git a/package-lock.json b/package-lock.json index bb9625216..93edb739d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -134,7 +134,6 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -1280,7 +1279,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", - "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -1764,7 +1762,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -1958,7 +1955,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2316,7 +2312,6 @@ "url": "https://github.com/sponsors/ai" } ], - "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -3097,7 +3092,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -4583,7 +4577,6 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, - "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -6204,7 +6197,6 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -7087,7 +7079,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7447,7 +7438,6 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, - "peer": true, "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -8323,7 +8313,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", - "peer": true, "requires": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -8734,7 +8723,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, - "peer": true, "requires": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -8843,8 +8831,7 @@ "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", - "dev": true, - "peer": true + "dev": true }, "acorn-jsx": { "version": "5.3.2", @@ -9102,7 +9089,6 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, - "peer": true, "requires": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -9660,7 +9646,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, - "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -10697,7 +10682,6 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, - "peer": true, "requires": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -11927,8 +11911,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", - "dev": true, - "peer": true + "dev": true }, "prettier-linter-helpers": { "version": "1.0.0", @@ -12538,8 +12521,7 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", - "dev": true, - "peer": true + "dev": true }, "unbox-primitive": { "version": "1.0.2", diff --git a/src/main.ts b/src/main.ts index 3b32fc9a8..f9456a216 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,26 +23,6 @@ type Options = { request?: RequestRequestOptions } -/** - * Gets the user agent string with orchestration ID appended if available - * @param userAgent The base user agent string - * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set - */ -function getUserAgentWithOrchestrationId(userAgent: string): string { - const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID'] - if (!orchestrationId) { - return userAgent - } - - // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') - if (!sanitized) { - return userAgent - } - - return `${userAgent} orchestration-id/${sanitized}` -} - async function main(): Promise { const token = core.getInput('github-token', {required: true}) const debug = core.getBooleanInput('debug') @@ -119,3 +99,23 @@ function handleError(err: any): void { console.error(err) core.setFailed(`Unhandled error: ${err}`) } + +/** + * Gets the user agent string with orchestration ID appended if available + * @param userAgent The base user agent string + * @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set + */ +function getUserAgentWithOrchestrationId(userAgent: string): string { + const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID'] + if (!orchestrationId) { + return userAgent + } + + // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') + if (!sanitized) { + return userAgent + } + + return `${userAgent} orchestration-id/${sanitized}` +} From 135f4fc944dbef19537891f338221876952f3b9f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:39:03 +0000 Subject: [PATCH 08/12] Replace invalid characters with underscore instead of removing them Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- dist/index.js | 4 ++-- package-lock.json | 24 +++++++++++++++++++++--- src/main.ts | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index 156802804..e39e65d53 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36325,8 +36325,8 @@ function getUserAgentWithOrchestrationId(userAgent) { if (!orchestrationId) { return userAgent; } - // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, ''); + // Sanitize orchestration ID - replace invalid characters with underscore + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_'); if (!sanitized) { return userAgent; } diff --git a/package-lock.json b/package-lock.json index 93edb739d..bb9625216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -134,6 +134,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -1279,6 +1280,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", + "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -1762,6 +1764,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -1955,6 +1958,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2312,6 +2316,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -3092,6 +3097,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -4577,6 +4583,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, + "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -6197,6 +6204,7 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -7079,6 +7087,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7438,6 +7447,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, + "peer": true, "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -8313,6 +8323,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", + "peer": true, "requires": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -8723,6 +8734,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, + "peer": true, "requires": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -8831,7 +8843,8 @@ "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", - "dev": true + "dev": true, + "peer": true }, "acorn-jsx": { "version": "5.3.2", @@ -9089,6 +9102,7 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, + "peer": true, "requires": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -9646,6 +9660,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, + "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -10682,6 +10697,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, + "peer": true, "requires": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -11911,7 +11927,8 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", - "dev": true + "dev": true, + "peer": true }, "prettier-linter-helpers": { "version": "1.0.0", @@ -12521,7 +12538,8 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", - "dev": true + "dev": true, + "peer": true }, "unbox-primitive": { "version": "1.0.2", diff --git a/src/main.ts b/src/main.ts index f9456a216..782aa2ad0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -111,8 +111,8 @@ function getUserAgentWithOrchestrationId(userAgent: string): string { return userAgent } - // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores - const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '') + // Sanitize orchestration ID - replace invalid characters with underscore + const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_') if (!sanitized) { return userAgent } From b588811d63c7d8bdd63791ed2d160f45d145fa92 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:46:11 +0000 Subject: [PATCH 09/12] Revert package-lock.json changes to remove peer flags Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- package-lock.json | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index bb9625216..93edb739d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -134,7 +134,6 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -1280,7 +1279,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", - "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -1764,7 +1762,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -1958,7 +1955,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2316,7 +2312,6 @@ "url": "https://github.com/sponsors/ai" } ], - "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -3097,7 +3092,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -4583,7 +4577,6 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, - "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -6204,7 +6197,6 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -7087,7 +7079,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -7447,7 +7438,6 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", "dev": true, - "peer": true, "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -8323,7 +8313,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz", "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==", - "peer": true, "requires": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.0.0", @@ -8734,7 +8723,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==", "dev": true, - "peer": true, "requires": { "@typescript-eslint/scope-manager": "6.7.5", "@typescript-eslint/types": "6.7.5", @@ -8843,8 +8831,7 @@ "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", - "dev": true, - "peer": true + "dev": true }, "acorn-jsx": { "version": "5.3.2", @@ -9102,7 +9089,6 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, - "peer": true, "requires": { "caniuse-lite": "^1.0.30001541", "electron-to-chromium": "^1.4.535", @@ -9660,7 +9646,6 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, - "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -10697,7 +10682,6 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, - "peer": true, "requires": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -11927,8 +11911,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", - "dev": true, - "peer": true + "dev": true }, "prettier-linter-helpers": { "version": "1.0.0", @@ -12538,8 +12521,7 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", - "dev": true, - "peer": true + "dev": true }, "unbox-primitive": { "version": "1.0.2", From c36bdc0a3af49bb7e233895cd63396b412308f6f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 22:55:13 +0000 Subject: [PATCH 10/12] Fix user-agent to handle empty string correctly Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- dist/index.js | 2 +- src/main.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index e39e65d53..67f5d4e17 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36267,7 +36267,7 @@ async function main() { const retries = parseInt(core.getInput('retries')); const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes')); const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults); - const baseUserAgent = userAgent || 'actions/github-script'; + const baseUserAgent = userAgent === '' ? '' : userAgent || 'actions/github-script'; const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent); const opts = { log: debug ? console : undefined, diff --git a/src/main.ts b/src/main.ts index 782aa2ad0..fa8083506 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,8 @@ async function main(): Promise { defaultGitHubOptions ) - const baseUserAgent = userAgent || 'actions/github-script' + const baseUserAgent = + userAgent === '' ? '' : userAgent || 'actions/github-script' const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent) const opts: Options = { From c0078b207260b6c0a6565c83bb165cb7ec7471cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 23:05:20 +0000 Subject: [PATCH 11/12] Simplify user-agent logic and update integration test Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- .github/workflows/integration.yml | 2 +- dist/index.js | 5 +---- src/main.ts | 6 +----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 346a57f2e..06827f277 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -167,7 +167,7 @@ jobs: exit 1 fi echo "- Validating user-agent set to an empty string" - expected="octokit-core.js/" + expected="actions/github-script octokit-core.js/" if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}" exit 1 diff --git a/dist/index.js b/dist/index.js index 67f5d4e17..06db0a26a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36267,7 +36267,7 @@ async function main() { const retries = parseInt(core.getInput('retries')); const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes')); const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults); - const baseUserAgent = userAgent === '' ? '' : userAgent || 'actions/github-script'; + const baseUserAgent = userAgent || 'actions/github-script'; const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent); const opts = { log: debug ? console : undefined, @@ -36327,9 +36327,6 @@ function getUserAgentWithOrchestrationId(userAgent) { } // Sanitize orchestration ID - replace invalid characters with underscore const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_'); - if (!sanitized) { - return userAgent; - } return `${userAgent} orchestration-id/${sanitized}`; } diff --git a/src/main.ts b/src/main.ts index fa8083506..d1f755c88 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,8 +39,7 @@ async function main(): Promise { defaultGitHubOptions ) - const baseUserAgent = - userAgent === '' ? '' : userAgent || 'actions/github-script' + const baseUserAgent = userAgent || 'actions/github-script' const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent) const opts: Options = { @@ -114,9 +113,6 @@ function getUserAgentWithOrchestrationId(userAgent: string): string { // Sanitize orchestration ID - replace invalid characters with underscore const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_') - if (!sanitized) { - return userAgent - } return `${userAgent} orchestration-id/${sanitized}` } From b67a9727973e68c3e61bf7a937078f9dcc745455 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 04:17:15 +0000 Subject: [PATCH 12/12] Change orchestration ID format to actions_orchestration_id Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- dist/index.js | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 06db0a26a..19ad994c3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36327,7 +36327,7 @@ function getUserAgentWithOrchestrationId(userAgent) { } // Sanitize orchestration ID - replace invalid characters with underscore const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_'); - return `${userAgent} orchestration-id/${sanitized}`; + return `${userAgent} actions_orchestration_id/${sanitized}`; } })(); diff --git a/src/main.ts b/src/main.ts index d1f755c88..cbf65693c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -114,5 +114,5 @@ function getUserAgentWithOrchestrationId(userAgent: string): string { // Sanitize orchestration ID - replace invalid characters with underscore const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_') - return `${userAgent} orchestration-id/${sanitized}` + return `${userAgent} actions_orchestration_id/${sanitized}` }