Remove comment only ProductInfoHeaderValue
See original GitHub issueVersion
all, but particularly 4.11.+
Describe the bug
In 4.11, we have added a constructor to ConnectorClient which takes an HttpClient. We then pass that HttpClient down to the underlying ServicClient’s constructor. Due to the fact that we have a ProductInfoHeaderValue which has no Product (comment only), the underlying ServiceClient will throw and catch 4 exceptions.
I’ve created a PR to address this within ServiceClient, but they have recommended we remove the comment only ProductInfoHeaderValue: https://github.com/Azure/azure-sdk-for-net/pull/16252
To Reproduce
Steps to reproduce the behavior: Run this test:
[Fact]
public void ConnectorClient_CustomHttpClient_UserAgentHeaderAdds()
{
var httpClient = new HttpClient();
ConnectorClient.AddDefaultRequestHeaders(httpClient);
using (var connector = new ConnectorClient(new Uri("http://localhost/"), new MicrosoftAppCredentials(string.Empty, string.Empty), customHttpClient: httpClient, disposeHttpClient: false))
{
// Use the connector
}
Assert.Equal(6, httpClient.DefaultRequestHeaders.UserAgent.Count);
}
Notice, none of the ServiceClient UserAgent headers have been added.
Expected behavior
Underlying ServiceClient UserAgent headers are added.
Remove the comment only product info header, and re-run the above test. It will pass. https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Connector/ConnectorClientEx.cs#L200
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
The recommendation for anyone seeing a null reference exception due to this is to ignore.
Hi @sebnema
I’m sorry you’ve spent time investigating this. The root cause is a known issue. You are correct, that the problem is in ServiceClient and has been present for years now. They are apprehensive to take a fix at this level of the core product: https://github.com/Azure/azure-sdk-for-net/pull/16252
The reason the Bot Builder sdk has not had this issue until 4.11.0 is because we were not using the ServiceClient constructor with HttpClient param, until 4.11.0: https://github.com/microsoft/botbuilder-dotnet/commit/918c54778e0c0e48187560661f208e034ceffb31#diff-914b91edd6e7e20fb74559dea5488a0b0ee7d63a197cd703135fb1adf44d079a
Our plan to resolve this in 4.12.0 is to replace the comment only ProductInfoHeaderValue in the Bot Builder SDK with one containing a product.