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.
Treat empty settings file as missing #35527
pull benthecarman wants to merge 1 commits into bitcoin:master from benthecarman:empty-settings-json changing 2 files +16 −7-
benthecarman commented at 5:39 PM on June 13, 2026: contributor
-
4647b6d066
Treat empty settings file as missing
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 commented at 5:40 PM on June 13, 2026: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35527.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
Type Reviewers Concept ACK winterrdog If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--174a7506f384e20aa4161008e828411d-->
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.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
-
winterrdog commented at 8:02 PM on June 13, 2026: contributor
concept ACK
-
mostafarahimifard commented at 8:31 PM on June 13, 2026: none
سلام وقت بخیر خسته نباشید
لطفا راهنمایی کنیدتا بفهمیم باید چکار کنم.
ممنون از لطفتون
در تاریخ شنبه ۱۳ ژوئن ۲۰۲۶، ۲۱:۱۴ benthecarman @.***> نوشت:
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.
You can view, comment on, or merge this pull request online at:
#35527 Commit Summary
- 4647b6d https://github.com/bitcoin/bitcoin/pull/35527/commits/4647b6d0661c7481beaa6a0c121e66346b135172 Treat empty settings file as missing
File Changes
(2 files https://github.com/bitcoin/bitcoin/pull/35527/files)
- M src/common/settings.cpp https://github.com/bitcoin/bitcoin/pull/35527/files#diff-89b7243ea2593828d4de9a8a10ad5f0a82cdfd57c1d34fb57a8b13b4fe7b8d98 (17)
- M src/test/settings_tests.cpp https://github.com/bitcoin/bitcoin/pull/35527/files#diff-24d440c41d48db2298a77b3488c7d8b75cd2d23ff697b7c78f091a615b3f1616 (6)
Patch Links:
— Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/35527?email_source=notifications&email_token=ASIMHXIR4AV5YSCDH4FVLZL47WHG7A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTQNRQGU3TMNRTHCTHEZLBONXW5KTTOVRHGY3SNFRGKZFFMV3GK3TUVRTG633UMVZF6Y3MNFRWW, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASIMHXNM7Q6TDGCZDG4NKQL47WHG7AVCNFSNUABDKJSXA33TNF2G64TZHMYTCOBRHEZDOO2JONZXKZJ3GQ3DKNRTGU2TSMRVUF3AE . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/ASIMHXIWTFRWZKUP5HLDCKT47WHG7A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTQNRQGU3TMNRTHCTHEZLBONXW5KTTOVRHGY3SNFRGKZFFMV3GK3TUVJTG633UMVZF62LPOM and Android https://github.com/notifications/mobile/android/ASIMHXLU45F5XAOKIOMLBGD47WHG7A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF4ZTQNRQGU3TMNRTHCTHEZLBONXW5KTTOVRHGY3SNFRGKZFFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE. Download it today! You are receiving this because you are subscribed to this thread.Message ID: @.***>
- bitcoin blocked a user on Jun 13, 2026
-
in src/common/settings.cpp:94 in 4647b6d066
89 | + errors.emplace_back(strprintf("Failed reading settings file %s", fs::PathToString(path))); 90 | + return false; 91 | + } 92 | + file.close(); // Done with file descriptor. Release while copying data. 93 | + 94 | + if (contents.empty()) return true;
maflcko commented at 8:04 AM on June 15, 2026: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 https://github.com/bitcoin/bitcoin/pull/35384
benthecarman commented at 4:24 PM on June 15, 2026: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.
ryanofsky commented at 10:28 PM on June 15, 2026: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.
benthecarman commented at 2:57 AM on June 16, 2026:that would fix my issues if that would be preferred
maflcko commented at 3:05 PM on June 17, 2026: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 added the label Needs rebase on Jun 19, 2026DrahtBot commented at 11:45 AM on June 19, 2026: contributor<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 This pull request conflicts with the target branch and needs rebase.
fanquake closed this on Jun 19, 2026
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-06-20 23:51 UTC
More mirrored repositories can be found on mirror.b10c.me