Skip to content

Corrupt settings file is silently overwritten with defaults, losing presets and hotkeys #65

Closed

Description

@TMHSDigital

Why it matters

If autoclicker_settings.json is ever unreadable (a hand edit with a trailing comma, a disk hiccup, an antivirus quarantine), the app quietly starts with defaults and the next save overwrites the file, permanently deleting the user's presets and custom hotkeys. Saves happen often (theme toggle, target mode change, every Start, on exit), so the loss happens within seconds and the only trace is a warning in autoclicker.log. The README actively invites editing the file ("All settings keys", e.g. max_cps_ceiling), which makes this more likely.

Evidence

  • autoclicker/core/settings_manager.py:105-118: on json.JSONDecodeError or a non-object, log a warning and return defaults.
  • SettingsManager.set / update (lines 131-139) immediately save the whole in-memory dict via atomic_write_json, replacing the bad file.
  • Loaded values are merged without type checks ({**self._defaults(), **loaded_settings}), so e.g. "presets": [] or "hotkeys": "F6" from a hand edit flows into PresetManager / HotkeyManager and fails later in less obvious places.

Suggested approach

  1. On a parse failure, rename the bad file to autoclicker_settings.json.corrupt-<timestamp> before using defaults, and say so once in the status bar ("Settings file was unreadable; saved a copy as ...").
  2. Per key, replace values of the wrong type with the default and log it, instead of trusting the file wholesale.
  3. Optional: keep one rolling autoclicker_settings.json.bak written before each save.

Done when

  • A corrupt settings file is preserved on disk, never silently overwritten, and the user is told where it went.
  • Wrong-typed keys fall back per key without crashing.
  • Tests cover invalid JSON, non-object JSON, and wrong-typed presets / hotkeys.

Activity

  1. added
    bug
    priority: medium
    on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions