fix(config): handle malformed prep_cmd and dd_mode_remapping JSON in config - #5500
Open
Rohan-Vij wants to merge 1 commit into
Open
fix(config): handle malformed prep_cmd and dd_mode_remapping JSON in config#5500Rohan-Vij wants to merge 1 commit into
Rohan-Vij wants to merge 1 commit into
Conversation
read_json/get_child throw ptree_error (json_parser_error or ptree_bad_path), which derive from std::runtime_error rather than filesystem_error. config::parse() only guards apply_config() with filesystem_error handlers, so a malformed global_prep_cmd or dd_mode_remapping value escaped to main() and terminated the process. Because the bad value is persisted in the config, Sunshine then failed to start on every launch (crash loop). Wrap the JSON parsing in list_prep_cmd_f() and mode_remapping_from_view() so an invalid value is logged and skipped (falling back to the default) instead of aborting startup. Add tests/unit/test_config.cpp covering the malformed, missing-key, and valid parse paths for both helpers.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Description
The existing try/catch for loading the config file (
apply_config()) only catches filesystem-level errors, not JSON schema errors. If either of the two JSON blobs (stored as strings) in the config file (global_prep_cmd,dd_mode_remapping) is malformed, they are not caught by the catch clauses, and Sunshine never starts up until the typo/error is fixed. Because the web UI does not currently have input validation, this error is likely to occur. The fix catches JSON parsing issues specifically either inglobal_prep_cmdordd_mode_remappingand returns the default for either config if malformed, letting Sunshine start with a malformed config (which can be reported in logging).Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage
See our AI usage policy.