From 97f5a6f0dc2fa3cffaea57ed0779ba957a14ad8f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:03:26 +0000 Subject: [PATCH] Simplify constructor by handling undefined in helper method Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com> --- packages/http-client/src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/http-client/src/index.ts b/packages/http-client/src/index.ts index e2e21f57..352fa106 100644 --- a/packages/http-client/src/index.ts +++ b/packages/http-client/src/index.ts @@ -147,9 +147,7 @@ export class HttpClient { handlers?: ifm.RequestHandler[], requestOptions?: ifm.RequestOptions ) { - this.userAgent = userAgent - ? this._getUserAgentWithOrchestrationId(userAgent) - : undefined + this.userAgent = this._getUserAgentWithOrchestrationId(userAgent) this.handlers = handlers || [] this.requestOptions = requestOptions if (requestOptions) { @@ -818,7 +816,12 @@ export class HttpClient { return proxyAgent } - private _getUserAgentWithOrchestrationId(userAgent: string): string { + private _getUserAgentWithOrchestrationId( + userAgent?: string + ): string | undefined { + if (!userAgent) { + return undefined + } const orchId = process.env['ACTIONS_ORCHESTRATION_ID'] if (orchId) { // Sanitize the orchestration ID to ensure it contains only valid characters