Skip to content

GeneratedClient constructor should not mutate the options bag #1039

@jeremymeng

Description

@jeremymeng

my convenience layer code creates two clients using the same options bag:

     const authClient = new GeneratedClient(endpoint, internalPipelineOptions);
     this.client = new GeneratedClient(endpoint, internalPipelineOptions);

It leads to duplicate library infor in user-agent header for the second client because the generated client's constructor updated options.userAgentOptions.userAgentPrefix. I fixed it by

-    options.userAgentOptions = {
-      userAgentPrefix: userAgentPrefix
-    };
-
     const optionsWithDefaults = {
       ...defaults,
       ...options,
+      userAgentOptions: {
+        userAgentPrefix
+      },
       baseUri: options.endpoint || "{url}"
     };

Metadata

Metadata

Assignees

Labels

bugThis issue requires a change to an existing behavior in the product in order to be resolved.v6

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions