Skip to content

Conversation

@willcl-ark
Copy link
Member

@willcl-ark willcl-ark commented Mar 10, 2023

fixes #22638

Make GUI "Settings file could not be read. Do you want to reset settings to default values?" dialog actually clear all settings instead of partially keeping them when settings.json contains duplicate keys. This change has no effect on bitcoind because it treats a corrupt settings.json file as a hard error and doesn't attempt to modify it.

If we find a duplicate key and error, clear values before returning so that WriteSettings() will write an empty file, therefore clearing it.

This aligns with GUI behaviour added in 1ee6d0b.

The test added only checks that values is empty after a duplicate key is detected. This paves the way for the abort option in the GUI to properly clear settings.json, if the user selects the option, but the test does not currently check this entire mechanism (e.g. the file contents).

fixes bitcoin#22638

If we find a duplicate key and error, clear `values` before returning so that
WriteSettings will write an empty file, therefore clearing it.

This aligns with GUI behaviour added in 1ee6d0b.
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 10, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky, TheCharlatan

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 8fcbdad. Thanks for the fix! I would maybe update the PR description or add to it to describe behavior change of this PR:


bugfix: Fix broken GUI "Reset" button when settings.json contains duplicate keys

Make GUI "Settings file could not be read. Do you want to reset settings to default values?" dialog actually clear all settings instead of partially keeping them when settings.json contains duplicate keys. This change has no effect on bitcoind because it treats a corrupt settings.json file as a hard error and doesn't attempt to modify it.

@willcl-ark
Copy link
Member Author

Thanks @ryanofsky . I updated the PR description with your recommendation. Did you think I should update the commit title to "bugfix: Fix broken GUI "Reset" button when settings.json contains duplicate keys" also? I'm happy to do that if so.

@ryanofsky
Copy link
Contributor

Thanks @ryanofsky . I updated the PR description with your recommendation. Did you think I should update the commit title to "bugfix: Fix broken GUI "Reset" button when settings.json contains duplicate keys" also? I'm happy to do that if so.

Either way seems fine, it's just a choice of whether you think it's more useful to describe the goal of the PR or the implemenation of the PR. Another alternative to changing the title could be changing the first line "fixes #22638" to "fixes #22638, broken gui settings reset button when settings.json contains duplicate keys"

@sedited
Copy link
Contributor

sedited commented Mar 10, 2023

Code review ACK 8fcbdad

@fanquake fanquake merged commit 87af64a into bitcoin:master Mar 11, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 12, 2023
8fcbdad util: fix argsman dupe key error (willcl-ark)

Pull request description:

  fixes bitcoin#22638

  Make GUI "Settings file could not be read. Do you want to reset settings to default values?" dialog actually clear all settings instead of partially keeping them when `settings.json` contains duplicate keys. This change has no effect on `bitcoind` because it treats a corrupt `settings.json` file as a hard error and doesn't attempt to modify it.

  If we find a duplicate key and error, clear `values` before returning so that `WriteSettings()` will write an empty file, therefore clearing it.

  This aligns with GUI behaviour added in 1ee6d0b.

  The test added only checks that `values` is empty after a duplicate key is detected. This paves the way for the `abort` option in the GUI to properly clear `settings.json`, if the user selects the option, but the test does not currently check this entire mechanism (e.g. the file contents).

ACKs for top commit:
  TheCharlatan:
    Code review ACK 8fcbdad
  ryanofsky:
    Code review ACK 8fcbdad. Thanks for the fix! I would maybe update the PR description or add to it to describe behavior change of this PR:

Tree-SHA512: a5fd49b30ede0a24188623192825bccb952e427cc35f96ff9bfdc737361dcc35ac6480589ddf7f0ddeaebd34361bdaee31e7a91f2c0d857e4ff682614bb6bc04
@bitcoin bitcoin locked and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ArgsManager::ReadSettingsFile can return false even when it does load settings

5 participants