Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spec for Action.Submit associated inputs #5079

Merged
merged 3 commits into from
Nov 19, 2020
Merged

Conversation

dclaux
Copy link
Member

@dclaux dclaux commented Nov 11, 2020

Related issue

[NodeJS][UX] Unable to have two SubmitAction Buttons and validation #5078

Description

This PR adds a small spec to allow actions to bypass input validation.

Microsoft Reviewers: Open in CodeFlow

@ghost
Copy link

ghost commented Nov 17, 2020

Hi @dclaux. This non-spec pull request has had no recent activity for the past 5 days . Please take the necessary actions (review, address feedback or commit if reviewed already) to move this along.

@RebeccaAnne RebeccaAnne added Spec Design Discussion - Needed Issue requires a design discussion before proceeding labels Nov 17, 2020
{
"type": "Action.Submit",
"title": "Cancel",
"ignoreInputValidation": true
Copy link
Contributor

Choose a reason for hiding this comment

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

My only concern with this is whether it's consistent with what we may someday want to do for associated inputs. The thinking on that was that we'd have some sort of associated inputs property that could be "All" "None" or an array of ids (default to All for Submit actions). If we had that, it would be redundant with this. We could name this in such a way that it more naturally expands to that. For example a property called validationInputs (or something) that today could be "All" or "None" (default to All, only available on Submit/Execute actions today) but in the future could expand to include an array of selected inputs and/or more input types if we want.

Copy link
Member Author

@dclaux dclaux Nov 17, 2020

Choose a reason for hiding this comment

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

Totally fair, and I have no problem using a design that would work well with that future evolution. Two options IMO:

  1. I don't think ignoreInputValidation would interfere/be redundant. We could later introduce an associatedInputs property which would list the ids of the inputs the action is tied to in an array. If unspecified, the assumption is "all the inputs" e.g. our current behavior. If specified, it has to be the exhaustive list of associated inputs. 'ignoreInputValidation` would remain the way to say "don't validate any input"

  2. Instead of ignoreInputValidation we go for something like associatedInputs whose value can be:

    • unspecified or "all": validate all the inputs
    • "none": don't validate any input
    • Array of input Ids: only validate these inputs

The JS SDK would be able to accommodate option 2 without introducing any breaking change.

I am not sure I have a strong preference, but obviously I'd go with option 1 since JS already implements ignoreInputValidation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer 2, it feels a little cleaner to me, but let's talk about it at the Wednesday meeting this week and run it by the team.

Copy link
Member

Choose a reason for hiding this comment

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

I like option 2.

Specifically, the first iteration could be something like:

associatedInputs = auto (default) | none

Where auto is equivalent to the current behavior, and none disables validation.

We can later introduce all and [id's...] as possible options when we are ready to ship associated inputs.

But one question - does an "unassociated" input also not get submitted in the data of that submit? i.e. Is enabling validation coupled with submitting data?

Copy link
Member Author

Choose a reason for hiding this comment

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

The Action.Http model in Outlook has always relied on explicitly referenced inputs (although using a different mechanism) and only the values of the referenced inputs are passed to the service. It seems to me that we should follow the same model.

@golddove do you see a difference between "auto" and "all"? Do you think we will really need both? So far, we've only ever done "all" (although we slightly changed the behavior when we introduced validation) so I'm not sure "auto" is necessary.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, going back to this bug, ignoring input validation would also have the side effect of disabling all data submission. Are we okay with that limitation? One option is to partition the data (our API would provide a list of associatedInput data, and otherInput data on submit).

And, yes, I'm referring to that slightly changed behavior we introduced (which doesn't submit all inputs). If we don't want to introduce a breaking change again on all renderers for this, we have to retain that as the default.

As for whether we really need the true all option that submits all inputs, I think it would be nice, but don't have a strong opinion on it. That's something we don't have to decide now.

Copy link
Member Author

@dclaux dclaux Nov 17, 2020

Choose a reason for hiding this comment

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

Not if we keep ignoreInputValidation as a separate flag. With that model it's clear that:

  • You enable or disable input validation using ignoreInputValidation
  • You specify which input values need to be transmitted to the backend service using associatedInputs - and if ignoreInputValidation is false, those inputs are also validated

Copy link
Member Author

Choose a reason for hiding this comment

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

And by the way I don't believe we need to distinguish between "all" and the "almost all" model we now have. "all" is enough IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should ever be sending un-validated data back to the backend. That seems likely to cause problems as code may assume that all inputs with validation have been validated client side. I think that validating and submission should be tied, so if it's not validated that's the same as not sent. Does anyone have a scenario where someone would want to send back an input that has validation without enforcing that validation? I think a schema/behavior that lets you ignore validation but still submit the inputs is making it a little too easy for card authors to shoot themselves in the foot. To me that means at the very least we should rename ignoreInputValidation to make it clear it affects submission as well. Really though I think we should just go with option 2.

On the auto/all topic, I agree with Risheek that we should call the value "auto" because explicitly calling it "all" and then not sending all the inputs is weird. Our behavior is a bit non-intuitive here already, and I don't think we'll improve the situation by "lying" about it :)

For what it's worth I don't feel strongly about whether we'll ever need to introduce an actual "all." It might come in handy, but if we have associated inputs the card author could do it manually if they really want. In any case that's a discussion for another day and outside the scope of this issue.

@ghost ghost removed the no-recent-activity label Nov 17, 2020
@ghost
Copy link

ghost commented Nov 17, 2020

Hi @RebeccaAnne; Thanks for reviewing this previously stale pull request. Resetting staleness. @dclaux FYI.

@RebeccaAnne
Copy link
Contributor

Per discussion we have agreed to add an associatedInputs property to Action.Submit. Current possible values are:
associatedInputs = auto (default) | none

If none is set, the values are neither validated nor returned to the host as part of the submit event.

@RebeccaAnne RebeccaAnne modified the milestones: 21.01, 20.11 Nov 18, 2020
@ghost ghost added the AdaptiveCards v20.11 label Nov 18, 2020
@RebeccaAnne RebeccaAnne modified the milestones: 20.11, 20.12 Nov 18, 2020
@dclaux dclaux changed the title Add spec for ignoreInputValidatiomn Spec for Action.Submit associated inputs Nov 18, 2020
@dclaux dclaux changed the title Spec for Action.Submit associated inputs Add spec for Action.Submit associated inputs Nov 18, 2020
@dclaux
Copy link
Member Author

dclaux commented Nov 18, 2020

Spec is updated according to our decision.

@ghost ghost removed the AdaptiveCards v20.11 label Nov 19, 2020
@dclaux dclaux merged commit 3a1d6c8 into main Nov 19, 2020
@dclaux dclaux deleted the ignore-input-validation branch November 19, 2020 01:05
@shalinijoshi19 shalinijoshi19 modified the milestones: 20.12, 20.11-12 Nov 20, 2020
@ghost ghost added the AdaptiveCards v20.11 label Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Discussion - Needed Issue requires a design discussion before proceeding Spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants