Compare commits

...

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 130335a4d9 Remove test for orchestration ID with only invalid characters
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-08 17:30:31 +00:00
copilot-swe-agent[bot] 818b5b3072 Simplify orchestration ID validation to accept any non-empty sanitized value
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-08 16:22:38 +00:00
3 changed files with 2 additions and 39 deletions

View File

@ -492,39 +492,4 @@ describe('git user-agent with orchestration ID', () => {
'git/2.18 (github-actions-checkout)'
)
})
it('should not append orchestration ID when it becomes empty after sanitization', async () => {
const orchId = '()///'
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
let capturedEnv: any = null
mockExec.mockImplementation((path, args, options) => {
if (args.includes('version')) {
options.listeners.stdout(Buffer.from('2.18'))
}
// Capture env on any command
capturedEnv = options.env
return 0
})
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
const workingDirectory = 'test'
const lfs = false
const doSparseCheckout = false
git = await commandManager.createCommandManager(
workingDirectory,
lfs,
doSparseCheckout
)
// 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
expect(git).toBeDefined()
expect(capturedEnv).toBeDefined()
expect(capturedEnv['GIT_HTTP_USER_AGENT']).toBe(
'git/2.18 (github-actions-checkout)'
)
})
})

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}`
}
}