[PR #4961] Gracefully handle json data with the wrong value types #26058

Closed
opened 2026-01-31 09:13:39 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4961

State: closed
Merged: Yes


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
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4961 **State:** closed **Merged:** Yes --- ## 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 `bool`s as `int`s, `float`s as `int`s, 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 * [x] Closes #4299 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## 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
claunia added the pull-request label 2026-01-31 09:13:39 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26058