microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.45k forks source link

Update 3.13.0.3 breaks FormFlow .Field using enum #4126

Closed MNHarun closed 6 years ago

MNHarun commented 6 years ago

Bot Info

Issue Description

I'm doing simple FormFlow with just 3 input and save responses to UserData (stored using local CosmosDB simulator). First input is from enum (Yes or No), indicating whether to proceed or not. The other two are strings and SetActive depending on the first input button selection. The first input is not saved to UserData, only the two strings are saved.

Update to 3.13.0.3. Start debug and cannot even start the conversation, 500 Internal Server Error. I delete botdb database in the CosmosDB simulator and I can start conversation. Now the and button appears but nothing happen when clicked. Normally, when I click on Yes, its as though I responded with Yes. When nothing happen with click, I typed Yes (and also tried number 1) and the conversation continues.

Now, running 3.13.0.3. all choices from enum not working.

One more, UserData created using 3.12.2.4 is not compatible with 3.13.0.3?

Code Example (with issue)

public enum AddOfficial { Yes = 1, No = 2 }

[Serializable]
public class OfficialInfo
{
    public TextLabels.AddOfficial? AskAddOfficial { get; set; }
    public string OfficialName { get; set; }
    public string OfficialID { get; set; }

    public static IForm<OfficialInfo> BuildForm()
    {
        return new FormBuilder<OfficialInfo>()
            .Field(new FieldReflector<OfficialInfo>(nameof(AskAddOfficial))
                .SetPrompt(new PromptAttribute(TextLabels.PromptSetOfficialPersonalNFOAsk + "{||}"))
                .SetFieldDescription(new DescribeAttribute(TextLabels.DescribeSetOfficialPersonalNFOAsk))
                .SetActive(x => true)
                .SetNext((value, x) =>
                {
                    if (x.AskAddOfficial.Value == TextLabels.AddOfficial.Yes)
                    {
                        return new NextStep(new[] { nameof(OfficialName) });
                    }
                    else if (x.AskAddOfficial.Value == TextLabels.AddOfficial.No) { return new NextStep(); }
                    else { return new NextStep(new[] { nameof(AskAddOfficial) }); }
                }))

            .Field(new FieldReflector<OfficialInfo>(nameof(OfficialName))
                .SetPrompt(new PromptAttribute(TextLabels.PromptSetPersonalNFOOfficialName))
                .SetFieldDescription(new DescribeAttribute(TextLabels.DescribeSetPersonalNFOOfficialName))
                .SetActive(x => !x.AskAddOfficial.HasValue || x.AskAddOfficial == TextLabels.AddOfficial.Yes)
                )

            .Field(new FieldReflector<OfficialInfo>(nameof(OfficialID))
                .SetPrompt(new PromptAttribute(TextLabels.PromptSetPersonalNFOOfficialID))
                .SetFieldDescription(new DescribeAttribute(TextLabels.DescribeSetPersonalNFOOfficialID))
                .SetActive(x => !x.AskAddOfficial.HasValue || x.AskAddOfficial == TextLabels.AddOfficial.Yes)
                )

        //.OnCompletion(SaveUserData)
        .Build();
    }
}
ghost commented 6 years ago

Yes, v3.13.0.3 broke form flow. It's not only specific to enums.

tiloc commented 6 years ago

Could this also result in other phenomena? After upgrading to 3.13.0.3 I experienced the problem described here (yes/no buttons no longer clickable) in Webchat, but on the same dialogs I am now also experiencing crashes on the Facebook connector. Is this related?

ghost commented 6 years ago

@tiloc I think so.

https://github.com/Microsoft/BotBuilder/compare/botbuilder@3.13.1...master#diff-22d3aafad398bb6777ae1c317a342eedL41

         /// </summary>
         public CardAction()
         {
-            this.Type = ActionTypes.ImBack;
+            CustomInit();
         }

-        /// The type of action implemented by this button. Defaults to <see cref="ActionTypes.ImBack"/>
+        /// An initialization method that performs custom operations like setting defaults
+        /// </summary>
+        partial void CustomInit();
tiloc commented 6 years ago

I upgraded the nuget package to 3.13.1 and everything is back to normal. Yes/No is clickable in Web Chat and Facebook Messenger behaves again as desired.

ghost commented 6 years ago

@tiloc glad to hear that!

MNHarun commented 6 years ago

Well done 😊. Thank you.