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

Gracefully handle json data with the wrong value types #4961

Merged
5 commits merged into from
Mar 20, 2020

Conversation

zadjii-msft
Copy link
Member

Summary of the Pull Request

Currently, if the Terminal attempts to parse a setting that should be a bool
and the user provided a string, then we'll throw an exception while parsing the
settings, and display an error message that's pretty unrelated to the actual
problem.

The same goes for bools as ints, floats as ints, etc.

This PR instead updates our settings parsing to ensure that we check the type of
a json value before actually trying to get its parsed value.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

I made a bunch of JsonUtils helpers for this in the same vein as the
GetOptionalValue ones.

Notably, any other value type can safely be treated as a string value.

Validation Steps Performed

  • added tests
  • ran the Terminal and verified we can parse settings with the wrong types

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Mar 17, 2020
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Json::Utils is awesome

…rong-settings-types

# Conflicts:
#	src/cascadia/TerminalApp/Profile.cpp
@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Mar 20, 2020
@ghost ghost requested review from miniksa, DHowett-MSFT and leonMSFT March 20, 2020 20:19
@DHowett-MSFT DHowett-MSFT added the AutoMerge Marked for automatic merge by the bot when requirements are met label Mar 20, 2020
@ghost
Copy link

ghost commented Mar 20, 2020

Hello @DHowett-MSFT!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 99fa946 into master Mar 20, 2020
@ghost ghost deleted the dev/migrie/b/4299-wrong-settings-types branch March 20, 2020 20:35
@ghost
Copy link

ghost commented Apr 22, 2020

🎉Windows Terminal Preview v0.11.1121.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
3 participants