Repository navigation
Treat empty settings file as missing - #35527
benthecarman wants to merge 1 commit into
Conversation
An empty settings file can be left behind after manual creation or failed writes. Treat it like an absent file so startup continues with default settings while still rejecting malformed non-empty JSON.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35527. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
concept ACK |
This comment was marked as off-topic.
This comment was marked as off-topic.
| } | ||
| file.close(); // Done with file descriptor. Release while copying data. | ||
|
|
||
| if (contents.empty()) return true; |
There was a problem hiding this comment.
Why would this happen? IIUC it can only happen when out-of-space? In that case it seems better to keep the error message, so that the user can remove the corrupt file and deal with the out-of-space issue.
Possibly the error message can be adjusted, see #35384
There was a problem hiding this comment.
Yeah I got this from an out of space. Still to me seems weird to error on this file after I've fixed the out of space issue.
There was a problem hiding this comment.
There was a previous PR #23096 that I believe implemented the same change as this one. It doesn't seem like a safe change to me to just start the node normally if the settings file has been corrupted and existing settings could be lost. It seems safer to alert the user that settings data is gone and let them decide if they are ok with starting the node with default settings.
The caveat to this is that probably the settings.json file will only hold important settings for GUI users, and is currently unlikely to hold any settings that matter as much for bitcoind users. So it could be reasonable to suppress this error or downgrade it if the GUI is not being used.
There was a problem hiding this comment.
that would fix my issues if that would be preferred
There was a problem hiding this comment.
Why would this happen? IIUC it can only happen when out-of-space? In that case it seems better to keep the error message, so that the user can remove the corrupt file and deal with the out-of-space issue.
Possibly the error message can be adjusted, see #35384
Actually, there was a bug where the return value was wrong (true vs false), fixed in #35384.
So this issue should not happen anymore after #35384
Maybe this pull can be closed now?
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
Will close for now, given the merge (and backport) of #35384. |
An empty settings file can be left behind after manual creation or failed writes. Treat it like an absent file so startup continues with default settings while still rejecting malformed non-empty JSON.