Skip to content

Tighten up luisRecognizerOptionsV3 error handling #1946

@EricDahlvang

Description

@EricDahlvang

Versions

4.8.0

Describe the bug

If LUIS is not configured correctly, calls to the service will sometimes return an .error result. This should be checked and properly raised, rather than assuming a result is returned: https://github.com/microsoft/botbuilder-js/blob/master/libraries/botbuilder-ai/src/luisRecognizerOptionsV3.ts#L62

        const data = await fetch(uri, httpOptions)
        const response = await data.json();
// SHOULD CHECK FOR response.error HERE
        const result: RecognizerResult = {
            text: utterance,
            intents : getIntents(response.prediction),
            entities : extractEntitiesAndMetadata(response.prediction),
            sentiment: getSentiment(response.prediction),
            luisResult: (this.predictionOptions.includeAPIResults ? response : null)
        }

To Reproduce

Steps to reproduce the behavior:

  1. Use CoreBot from samples
  2. Set the LuisAppId to an id that does not exist
  3. Run the bot, and trigger a LUIS call
  4. See confusing error: TypeError: Cannot read property 'intents' of undefined

Expected behavior

A more descriptive error message should be shown. Preferably, the one LUIS returns.

Screenshots

If applicable, add screenshots to help explain your problem.
image

[bug]

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or an unintended behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions