Skip to content

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

@ryanofsky

Description

@ryanofsky

Credit to @luke-jr for helping uncovering this bug bitcoin-core/gui#379 (comment)

This bug has no user-visible effects currently, but combined with PR bitcoin-core/gui#379 and a corrupt settings.json file that is corrupted specifically by specifying the same JSON keys multiple times, it can cause some dialog text added in that PR to be misleading. This is a basically an impossible-to-hit rube goldberg bug, but is only fixable at the util level not the GUI level, so I'm tracking this outside the GUI repository.

Simplest fix would be to just change ReadSettingsFile to call rw_settings.clear() on error. It would also be nice to add a unit test for the regression.

Code path that triggers this is:

if (!util::ReadSettings(path, m_settings.rw_settings, read_errors)) {

errors.emplace_back(strprintf("Found duplicate key %s in settings file %s", in_keys[i], path.string()));

return errors.empty();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions