Skip to content

util: Treat empty settings.json file as valid - #23096

Closed
AaronDewes wants to merge 2 commits into
bitcoin:masterfrom
AaronDewes:allow-empty-settings-json
Closed

AaronDewes wants to merge 2 commits into
bitcoin:masterfrom
AaronDewes:allow-empty-settings-json

Conversation

@AaronDewes

Copy link
Copy Markdown

Previously, if the settings.json file was empty, it failed to parse.
Now, it is handled like non-existent, which should help avoid issues if

  • The user decides to empty it
  • The file gets saved improperly
  • The user touches it before starting Bitcoin Core

Previously, if the settings.json file was empty, it failed to parse.
Now, it is handled like non-existent, which should help avoid issues if

- The user decides to empty it
- The file gets saved improperly
- The user touches it before starting Bitcoin Core
@ryanofsky

Copy link
Copy Markdown
Contributor

A zero size settings file is a corrupt settings file, not different from other corrupt files. If critical settings that affect security, privacy, or performance (tor settings, pruning settings, etc) have been configured it could be harmful to ignore corruption like nothing happened.

For non interactive bitcoind use, when corrupt settings are detected I think the best thing bitcoin can do is print a clear and helpful error message and not start when it detects corruption. For interactive GUI use, the application can be more proactive and give an option to reset the corrupt file or move it out of the way.

The current behavior may not be ideal if the error message is not clear about the problem and potential fixes, or if the GUI is not presenting enough options. It seems useful to do a good job handling this case because the settings file is one of the first files read on startup, and if it has a problem, it could be indication of other problems with the datadir. Maybe also the settings file could be written in a more robust way, like maybe it would help to add a sync call before renaming on write. But I don't think allowing corruption would be a good thing to do here.

@AaronDewes AaronDewes closed this Sep 28, 2021
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
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.

3 participants