azure-sdk-for-net throws an exception on Mac












4















I am trying to use Azure Text analysis API SDK for dotnet (basically this nuget package). I am using Mac.



I get the following exception when I run the code (I use Mac):




The format of value 'Darwin17.7.0DarwinKernelVersion17.7.0WedOct10230614PDT2018rootxnu-4570.71.131/RELEASE_X86_64' is invalid.




This is the code that throws an exception:



var serviceClientCredentials = new AzureApiKeyServiceClientCredentials("<key>");
// Throw an exception here
var client = new TextAnalyticsClient(_serviceClientCredentials);


ServiceClientCredentials class:



public class AzureApiKeyServiceClientCredentials : ServiceClientCredentials
{
private readonly string _subscriptionKey;

public AzureApiKeyServiceClientCredentials(string subscriptionKey)
{
_subscriptionKey = subscriptionKey;
}

public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add("Ocp-Apim-Subscription-Key", _subscriptionKey);

return base.ProcessHttpRequestAsync(request, cancellationToken);
}
}


Source of the problem:



After trying to understand the source code I found out that TextAnalyticsClient tries to set a header key/value and the value is not valid http header value (i.e. Darwin..../RELEASE_X86_64). More specifically, I see in the source, it's setting OsVersion on the header of HttpClient and it's not url friendly value and HttpClient is throwing an exception:



this.UpdateDefaultUserAgentList("OSVersion", this.OsVersion);


I created an issue on GitHub. So, all they need to do it to fix it is to always call CleanUserAgentInfoEntry(_osVersion).



I see in their source that they are getting OsVersion from new PlatformInfo(); and I am wondering is it possible to change RuntimeInformation.OSDescription



Update:
I created a pull request to fix the issue.










share|improve this question

























  • I don't get it. Surely the code you linked to already always calls CleanUserAgentInfoEntry already. _osVersion is a private field: if it's not set, that code sets it and cleans it. Under what circumstances could it not be cleaned?

    – stuartd
    Nov 21 '18 at 20:47
















4















I am trying to use Azure Text analysis API SDK for dotnet (basically this nuget package). I am using Mac.



I get the following exception when I run the code (I use Mac):




The format of value 'Darwin17.7.0DarwinKernelVersion17.7.0WedOct10230614PDT2018rootxnu-4570.71.131/RELEASE_X86_64' is invalid.




This is the code that throws an exception:



var serviceClientCredentials = new AzureApiKeyServiceClientCredentials("<key>");
// Throw an exception here
var client = new TextAnalyticsClient(_serviceClientCredentials);


ServiceClientCredentials class:



public class AzureApiKeyServiceClientCredentials : ServiceClientCredentials
{
private readonly string _subscriptionKey;

public AzureApiKeyServiceClientCredentials(string subscriptionKey)
{
_subscriptionKey = subscriptionKey;
}

public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add("Ocp-Apim-Subscription-Key", _subscriptionKey);

return base.ProcessHttpRequestAsync(request, cancellationToken);
}
}


Source of the problem:



After trying to understand the source code I found out that TextAnalyticsClient tries to set a header key/value and the value is not valid http header value (i.e. Darwin..../RELEASE_X86_64). More specifically, I see in the source, it's setting OsVersion on the header of HttpClient and it's not url friendly value and HttpClient is throwing an exception:



this.UpdateDefaultUserAgentList("OSVersion", this.OsVersion);


I created an issue on GitHub. So, all they need to do it to fix it is to always call CleanUserAgentInfoEntry(_osVersion).



I see in their source that they are getting OsVersion from new PlatformInfo(); and I am wondering is it possible to change RuntimeInformation.OSDescription



Update:
I created a pull request to fix the issue.










share|improve this question

























  • I don't get it. Surely the code you linked to already always calls CleanUserAgentInfoEntry already. _osVersion is a private field: if it's not set, that code sets it and cleans it. Under what circumstances could it not be cleaned?

    – stuartd
    Nov 21 '18 at 20:47














4












4








4








I am trying to use Azure Text analysis API SDK for dotnet (basically this nuget package). I am using Mac.



I get the following exception when I run the code (I use Mac):




The format of value 'Darwin17.7.0DarwinKernelVersion17.7.0WedOct10230614PDT2018rootxnu-4570.71.131/RELEASE_X86_64' is invalid.




This is the code that throws an exception:



var serviceClientCredentials = new AzureApiKeyServiceClientCredentials("<key>");
// Throw an exception here
var client = new TextAnalyticsClient(_serviceClientCredentials);


ServiceClientCredentials class:



public class AzureApiKeyServiceClientCredentials : ServiceClientCredentials
{
private readonly string _subscriptionKey;

public AzureApiKeyServiceClientCredentials(string subscriptionKey)
{
_subscriptionKey = subscriptionKey;
}

public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add("Ocp-Apim-Subscription-Key", _subscriptionKey);

return base.ProcessHttpRequestAsync(request, cancellationToken);
}
}


Source of the problem:



After trying to understand the source code I found out that TextAnalyticsClient tries to set a header key/value and the value is not valid http header value (i.e. Darwin..../RELEASE_X86_64). More specifically, I see in the source, it's setting OsVersion on the header of HttpClient and it's not url friendly value and HttpClient is throwing an exception:



this.UpdateDefaultUserAgentList("OSVersion", this.OsVersion);


I created an issue on GitHub. So, all they need to do it to fix it is to always call CleanUserAgentInfoEntry(_osVersion).



I see in their source that they are getting OsVersion from new PlatformInfo(); and I am wondering is it possible to change RuntimeInformation.OSDescription



Update:
I created a pull request to fix the issue.










share|improve this question
















I am trying to use Azure Text analysis API SDK for dotnet (basically this nuget package). I am using Mac.



I get the following exception when I run the code (I use Mac):




The format of value 'Darwin17.7.0DarwinKernelVersion17.7.0WedOct10230614PDT2018rootxnu-4570.71.131/RELEASE_X86_64' is invalid.




This is the code that throws an exception:



var serviceClientCredentials = new AzureApiKeyServiceClientCredentials("<key>");
// Throw an exception here
var client = new TextAnalyticsClient(_serviceClientCredentials);


ServiceClientCredentials class:



public class AzureApiKeyServiceClientCredentials : ServiceClientCredentials
{
private readonly string _subscriptionKey;

public AzureApiKeyServiceClientCredentials(string subscriptionKey)
{
_subscriptionKey = subscriptionKey;
}

public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add("Ocp-Apim-Subscription-Key", _subscriptionKey);

return base.ProcessHttpRequestAsync(request, cancellationToken);
}
}


Source of the problem:



After trying to understand the source code I found out that TextAnalyticsClient tries to set a header key/value and the value is not valid http header value (i.e. Darwin..../RELEASE_X86_64). More specifically, I see in the source, it's setting OsVersion on the header of HttpClient and it's not url friendly value and HttpClient is throwing an exception:



this.UpdateDefaultUserAgentList("OSVersion", this.OsVersion);


I created an issue on GitHub. So, all they need to do it to fix it is to always call CleanUserAgentInfoEntry(_osVersion).



I see in their source that they are getting OsVersion from new PlatformInfo(); and I am wondering is it possible to change RuntimeInformation.OSDescription



Update:
I created a pull request to fix the issue.







c# azure .net-core






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 20:18







Node.JS

















asked Nov 21 '18 at 20:01









Node.JSNode.JS

9861941




9861941













  • I don't get it. Surely the code you linked to already always calls CleanUserAgentInfoEntry already. _osVersion is a private field: if it's not set, that code sets it and cleans it. Under what circumstances could it not be cleaned?

    – stuartd
    Nov 21 '18 at 20:47



















  • I don't get it. Surely the code you linked to already always calls CleanUserAgentInfoEntry already. _osVersion is a private field: if it's not set, that code sets it and cleans it. Under what circumstances could it not be cleaned?

    – stuartd
    Nov 21 '18 at 20:47

















I don't get it. Surely the code you linked to already always calls CleanUserAgentInfoEntry already. _osVersion is a private field: if it's not set, that code sets it and cleans it. Under what circumstances could it not be cleaned?

– stuartd
Nov 21 '18 at 20:47





I don't get it. Surely the code you linked to already always calls CleanUserAgentInfoEntry already. _osVersion is a private field: if it's not set, that code sets it and cleans it. Under what circumstances could it not be cleaned?

– stuartd
Nov 21 '18 at 20:47












1 Answer
1






active

oldest

votes


















0














I just solved the issue, thanks to @shahabhijeet. I installed the latest version of Microsoft.Rest.ClientRuntime and it solved the problem.



GitHub issue thread: https://github.com/Azure/azure-sdk-for-net/issues/5046






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419683%2fazure-sdk-for-net-throws-an-exception-on-mac%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I just solved the issue, thanks to @shahabhijeet. I installed the latest version of Microsoft.Rest.ClientRuntime and it solved the problem.



    GitHub issue thread: https://github.com/Azure/azure-sdk-for-net/issues/5046






    share|improve this answer




























      0














      I just solved the issue, thanks to @shahabhijeet. I installed the latest version of Microsoft.Rest.ClientRuntime and it solved the problem.



      GitHub issue thread: https://github.com/Azure/azure-sdk-for-net/issues/5046






      share|improve this answer


























        0












        0








        0







        I just solved the issue, thanks to @shahabhijeet. I installed the latest version of Microsoft.Rest.ClientRuntime and it solved the problem.



        GitHub issue thread: https://github.com/Azure/azure-sdk-for-net/issues/5046






        share|improve this answer













        I just solved the issue, thanks to @shahabhijeet. I installed the latest version of Microsoft.Rest.ClientRuntime and it solved the problem.



        GitHub issue thread: https://github.com/Azure/azure-sdk-for-net/issues/5046







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 0:39









        Node.JSNode.JS

        9861941




        9861941
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419683%2fazure-sdk-for-net-throws-an-exception-on-mac%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()