Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.09k stars 1.2k forks source link

[Text translation] TextTranslationClient error type mismatch: ErrorResponseOutput #27403

Open matt-parloa opened 1 year ago

matt-parloa commented 1 year ago

Describe the bug Using TextTranslationClient, and receiving an error response. The response.body returned by the client is a string. e.g. body: '{"error":{"code":401000,"message":"The request is not authorized because credentials are missing or invalid."}}' but the type defined in @azure-rest/ai-translation-text/types/ai-translation-text.d.ts is ErrorResponseOutput which is an object containing error: ErrorDetailsOutput.

To Reproduce Steps to reproduce the behavior:

  1. Trigger any error using the TextTranslationClient
  2. Attempt to reference res.body.error.message
  3. Get an error, Uncaught TypeError: Cannot read properties of undefined (reading 'message')

Expected behavior Either the response body is typed as a string, or the body is returned parsed as an object to match it's type definition.

github-actions[bot] commented 1 year ago

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