fix: prevent duplicate orchestration ID in user-agent

Add idempotency check to getUserAgentWithOrchestrationId — if the
tag is already present in baseUserAgent, return it unchanged. This
prevents doubling when both the exported helper and getOctokitOptions
run for the same client.
This commit is contained in:
Salman Chishti
2026-04-08 16:49:32 +00:00
committed by GitHub
parent b0917c5a37
commit ffeb50bd02
2 changed files with 21 additions and 1 deletions
+3 -1
View File
@@ -49,8 +49,10 @@ export function getUserAgentWithOrchestrationId(
const orchId = process.env['ACTIONS_ORCHESTRATION_ID']?.trim()
if (orchId) {
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_')
const tag = `actions_orchestration_id/${sanitizedId}`
if (baseUserAgent?.includes(tag)) return baseUserAgent
const ua = baseUserAgent ? `${baseUserAgent} ` : ''
return `${ua}actions_orchestration_id/${sanitizedId}`
return `${ua}${tag}`
}
return baseUserAgent
}