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

Fixes initial population of values for string Collections in the launch form. #48

Merged
merged 3 commits into from
Feb 20, 2020

Conversation

schottra
Copy link
Contributor

flyteorg/flyte#181

When converting Literal values to InputValues for use in the form, the Collection type is output as a JSON representation of an array. The existing implementation was blindly wrapping [] around values and comma-separating them. For Dates and strings, the resulting array string is not valid JSON and will trigger validation errors.

It turned out to be easier to allow JSON.stringify to do this work for us, with the exception of integers. Since we use a special type for integers, stringify would result in a quoted string value instead of a bare integer value.

@schottra schottra merged commit ad6ca06 into master Feb 20, 2020
Copy link
Contributor

@BobNisco BobNisco left a comment

Choose a reason for hiding this comment

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

A non-blocking suggestion inline

/** Converts a value within a collection to the appropriate string
* representation. Some values require additional quotes.
*/
export function collectionChildToString(type: InputType, value: any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be worthwhile to add an explicit return type of string here so that future code changes do not accidentally return unexpected types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea. Code consuming this expects a string, so changes here would still result in a type error. But I can't guarantee that any new usage of this function would also have such a strict type expectation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants