Simplify orchestration ID validation to accept any non-empty sanitized value

Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-08 16:22:38 +00:00
parent 4b8779770e
commit 818b5b3072
3 changed files with 5 additions and 7 deletions

View File

@ -493,7 +493,7 @@ describe('git user-agent with orchestration ID', () => {
)
})
it('should not append orchestration ID when it becomes empty after sanitization', async () => {
it('should sanitize orchestration ID to underscores when it contains only invalid characters', async () => {
const orchId = '()///'
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
@ -520,11 +520,11 @@ describe('git user-agent with orchestration ID', () => {
// Call a git command to trigger env capture after user-agent is set
await git.init()
// Verify the user agent does NOT contain orchestration ID when sanitized ID is empty
// Verify the user agent contains orchestration ID with sanitized underscores
expect(git).toBeDefined()
expect(capturedEnv).toBeDefined()
expect(capturedEnv['GIT_HTTP_USER_AGENT']).toBe(
'git/2.18 (github-actions-checkout)'
'git/2.18 (github-actions-checkout) actions_orchestration_id/_____'
)
})
})

3
dist/index.js vendored
View File

@ -1213,8 +1213,7 @@ class GitCommandManager {
// Sanitize the orchestration ID to ensure it contains only valid characters
// Valid characters: 0-9, a-z, _, -, .
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
// Only append if sanitized ID contains at least one alphanumeric character
if (sanitizedId && /[a-z0-9]/i.test(sanitizedId)) {
if (sanitizedId) {
gitHttpUserAgent = `${gitHttpUserAgent} actions_orchestration_id/${sanitizedId}`;
}
}

View File

@ -738,8 +738,7 @@ class GitCommandManager {
// Sanitize the orchestration ID to ensure it contains only valid characters
// Valid characters: 0-9, a-z, _, -, .
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_')
// Only append if sanitized ID contains at least one alphanumeric character
if (sanitizedId && /[a-z0-9]/i.test(sanitizedId)) {
if (sanitizedId) {
gitHttpUserAgent = `${gitHttpUserAgent} actions_orchestration_id/${sanitizedId}`
}
}