Add default user-agent 'actions/http-client' when none provided

Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-06 18:10:12 +00:00
parent 97f5a6f0dc
commit 3a191eecf6
2 changed files with 5 additions and 9 deletions
+4 -8
View File
@@ -816,20 +816,16 @@ export class HttpClient {
return proxyAgent
}
private _getUserAgentWithOrchestrationId(
userAgent?: string
): string | undefined {
if (!userAgent) {
return undefined
}
private _getUserAgentWithOrchestrationId(userAgent?: string): string {
const baseUserAgent = userAgent || 'actions/http-client'
const orchId = process.env['ACTIONS_ORCHESTRATION_ID']
if (orchId) {
// 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, '_')
return `${userAgent} actions_orchestration_id/${sanitizedId}`
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`
}
return userAgent
return baseUserAgent
}
private async _performExponentialBackoff(retryNumber: number): Promise<void> {