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
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:
Trigger any error using the TextTranslationClient
Attempt to reference res.body.error.message
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.
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
isErrorResponseOutput
which is an object containingerror: ErrorDetailsOutput
.To Reproduce Steps to reproduce the behavior:
res.body.error.message
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.