Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Conversation

@Danieladu
Copy link
Contributor

Original issue: https://github.com/microsoft/botbuilder-dotnet/issues/4758
Original PR: microsoft/botbuilder-dotnet#4814

Description

If someone assigns an empty string or null value or whitespace string to property OutputFormat, would trigger the unrecognized prompt error.

Specific Changes

Ignore the null or whitespace string in OutputFormat.

Testing

Such action:

{
           "$kind": "Microsoft.TextInput",
           "property": "user.name",
           "alwaysPrompt": true,
           "prompt": "Hello, what is your name?",
            "unrecognizedPrompt": "How should I call you?",
            "validations": [
                   "this.value.Length > 3"
             ],
             "outputFormat": "" // would ignore this property
 }

@Danieladu Danieladu requested a review from a team as a code owner October 20, 2020 02:08
Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick suggestion.

const value = this.outputFormat.getValue(dc.state);
input = value.toString();
if (value && value.trim()) {
input = value.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems strange to call toString() after calling trim() which implies value is a string. Also, do we want to assign the trimmed string to input? Maybe this should be:

const maybeValue = this.outputFormat.getValue(dc.state);
if (maybeValue && typeof maybeValue === 'string') {
  const value = maybeValue.trim();
  if (value) {
    input = value;
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The original toString() seems redundant because the return type of this.outputFormat.getValue(dc.state) is string | undefined, so, just remove the toString() is ok?

@stevengum stevengum added the Area: Adaptive The issue is related to Adaptive dialogs label Oct 20, 2020
@Danieladu Danieladu merged commit 03bcb8b into main Oct 21, 2020
@Danieladu Danieladu deleted the hond/outputFormat branch October 21, 2020 05:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Area: Adaptive The issue is related to Adaptive dialogs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants