Azure-sdk-for-js: No error, empty result when using endpoint URL from azure portal incorrectly

Created on 22 Apr 2020  路  6Comments  路  Source: Azure/azure-sdk-for-js

  • Package Name: @azure/cognitiveservices-translatortext
  • Package Version: 1.0.0
  • Operating system: Windows 10 2004 OS Build 19041.207
  • [ ] nodejs

    • version:

  • [x] browser

    • name/version: Edge Chromium Dev: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.3 Safari/537.36 Edg/83.0.478.5

  • [x] typescript

    • version: 3.8.3

  • Is the bug related to documentation in

This was the configuration where I encountered it, but I imagine it generalizes to other environments and packages.

Describe the bug
I'm not sure if this would be considered a bug or not. It is just some feedback about behavior that tripped me up. I'm still a beginner at all things TypeScript, JavaScript, Azure, REST. Maybe others in the same position would make the same mistake, and maybe the SDK can make it easier somehow to diagnose the mistake?

Making my first ever Azure service call, I got to the point where I needed to pass an endpoint. It seemed logical to me that the endpoint would be what the Azure portal showed me along with the key:

image

However, this was not correct. I needed to use https://api.cognitive.microsofttranslator.com instead, which I eventually found in Azure docs, but it took me quite a while to spot it. It would have been nice if the SDK pointed out my mistake by throwing an error, but instead I got a successful yet empty result from my API call, leading me to believe that my mistake must have been elsewhere.

To Reproduce
Steps to reproduce the behavior:

  1. Create a CognitiveServices TranslatorText resource in the azure portal
  2. Use the sample code here, using the endpoint (incorrectly) and key from azure portal

Expected behavior
An error is reported.

Acutal behavior
The code succeeds but returns an empty result.

Screenshots
This is what you get: 200 OK with an empty result.

image

Additional context
N/A

Client Cognitive - Translator Service Attention question

All 6 comments

(You can remove the "customer-reported" tag. I work at Microsoft, just joined the team, and found this while experimenting as a ramping up exercise.)

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dfulcer.

Thanks for reporting @nguerrera

This is an auto generated library based on the swagger specification from the service team.
From what I know, in this scenario, the client cannot make any validations on the provided endpoint and it is up to the service to throw an error.

@sarangan12, Please correct me if my understanding above is wrong

@ramya-rao-a The (incorrect)endpoint is configured in such a manner that it returns empty result which is acceptable to our SDK. From SDK side we cannot do much here.

On a side note, this was my experience too when I tried building samples a while back. The correct fix would be to fix the portal and display the correct endpoint. Else, all new devs would face this experience. Should be reported to the portal team

Thanks for the explanation. That makes sense. Is there someone we can tag into the conversation from the portal team?

@nguerrera, I believe each Azure service team has their own contacts for their parts of the portal. Please reach out to @dfulcer or @ChrisHMSFT to get more details. Also, I believe this problem is common to almost all Cognitive Services, not just translator text, something to keep in mind when we design a solution for this.

Was this page helpful?
0 / 5 - 0 ratings