Add underscore to valid orchestration ID characters

Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-06 21:27:04 +00:00
parent baada7bb39
commit f80dad6b51
3 changed files with 11 additions and 11 deletions

View file

@ -21,7 +21,7 @@ describe('getUserAgentWithOrchestrationId', () => {
process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId
// Simulate the logic from getUserAgentWithOrchestrationId // 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}` const result = `${baseUserAgent} orchestration-id/${sanitized}`
expect(result).toBe( expect(result).toBe(
@ -34,7 +34,7 @@ describe('getUserAgentWithOrchestrationId', () => {
const orchestrationId = 'test@orchestration#123!abc$xyz' const orchestrationId = 'test@orchestration#123!abc$xyz'
// Simulate the logic from getUserAgentWithOrchestrationId // 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}` const result = `${baseUserAgent} orchestration-id/${sanitized}`
expect(result).toBe( 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 baseUserAgent = 'actions/github-script'
const orchestrationId = 'test.orchestration-123' const orchestrationId = 'test.orchestration-123_abc'
// Simulate the logic from getUserAgentWithOrchestrationId // 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}` const result = `${baseUserAgent} orchestration-id/${sanitized}`
expect(result).toBe( 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 = '@#$%^&*()' const orchestrationId = '@#$%^&*()'
// Simulate the logic from getUserAgentWithOrchestrationId // 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 const result = sanitized
? `${baseUserAgent} orchestration-id/${sanitized}` ? `${baseUserAgent} orchestration-id/${sanitized}`
: baseUserAgent : baseUserAgent

4
dist/index.js vendored
View file

@ -36268,8 +36268,8 @@ function getUserAgentWithOrchestrationId(userAgent) {
if (!orchestrationId) { if (!orchestrationId) {
return userAgent; return userAgent;
} }
// Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, ''); const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '');
if (!sanitized) { if (!sanitized) {
return userAgent; return userAgent;
} }

View file

@ -34,8 +34,8 @@ function getUserAgentWithOrchestrationId(userAgent: string): string {
return userAgent return userAgent
} }
// Sanitize orchestration ID - only keep alphanumeric, dots, and hyphens // Sanitize orchestration ID - only keep alphanumeric, dots, hyphens, and underscores
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9.-]/g, '') const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
if (!sanitized) { if (!sanitized) {
return userAgent return userAgent
} }