Skip to content

Treat empty settings file as missing - #35527

Closed
benthecarman wants to merge 1 commit into
bitcoin:masterfrom
benthecarman:empty-settings-json
Closed

benthecarman wants to merge 1 commit into
bitcoin:masterfrom
benthecarman:empty-settings-json

Conversation

@benthecarman

Copy link
Copy Markdown
Contributor

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.

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.
@DrahtBot

DrahtBot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35527.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK winterrdog

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35384 (util: Check write failures before renaming settings.json by sh011)

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.

@winterrdog

Copy link
Copy Markdown
Contributor

concept ACK

@mostafarahimifard

This comment was marked as off-topic.

Comment thread src/common/settings.cpp
}
file.close(); // Done with file descriptor. Release while copying data.

if (contents.empty()) return true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that would fix my issues if that would be preferred

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

@DrahtBot

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@fanquake

Copy link
Copy Markdown
Member

Will close for now, given the merge (and backport) of #35384.

@fanquake fanquake closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants