Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add underscore to valid orchestration ID characters
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
  • Loading branch information
Copilot and TingluoHuang committed Jan 6, 2026
commit f80dad6b51802013cabd11375d6043da2278a627
14 changes: 7 additions & 7 deletions __test__/orchestration-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -34,24 +34,24 @@ 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(
'actions/github-script orchestration-id/testorchestration123abcxyz'
)
})

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'
)
})

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down