Skip to content

fix: keep the current mode when delete or an unknown mode is saved while the container runs - #318

Merged
chodeus merged 1 commit into
mainfrom
fix/runtime-mode-delete
Oct 15, 2026
Merged

chodeus merged 1 commit into
mainfrom
fix/runtime-mode-delete

Conversation

@chodeus

@chodeus chodeus commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

mode = delete runs the interactive delete at startup. The config reload didn't check the mode at all, so a delete saved while the container ran (by hand in beatscheck.conf or through the API), or a typo such as reprot, became the mode for every later pass. run_scan treats any mode it doesn't know like report, so the container went on scanning as if in report mode while the setting said otherwise, and a saved delete also cancelled a running rescan move.

Now:

  • _usable_saved_mode checks the saved mode at each reload. setup, report and move apply as before, in any letter case. For delete it logs that delete mode runs only at startup and points to docker exec -it beatscheck delete; for anything else it logs Unknown mode '…' in beatscheck.conf. Either way the current mode stays, so a rescan's mode also holds.
  • _RUNTIME_MODES (setup, report, move) lists the modes a running container can switch to. The WebUI save rejects any other mode with a 400 and leaves the file alone. The Settings select already offers only those three.
  • Startup is unchanged: MODE=delete still runs the interactive delete, and an unknown mode still stops the container with an error.

docs/configuration.md describes this in the mode row.

Testing

  • New tests/test_runtime_mode.py (5 tests, 8 cases):
    • A saved delete keeps the current mode and logs the docker exec line; an unknown mode keeps it and logs the name.
    • A saved mode in capitals still applies.
    • A saved delete doesn't end a rescan move.
    • The WebUI save refuses delete, an unknown mode and a number, and accepts Move.
  • On the old code, 6 of the 8 cases fail; the two that pass (capitals, Move accepted) are guards for behaviour that already worked.
  • Each test was checked against a mutation of the code it covers; 6 of 6 mutations were caught.
  • Full suite: 397 passed. flake8 and ruff clean.

Summary by CodeRabbit

  • Bug Fixes

    • Runtime configuration updates now retain the current mode if the saved setting is delete or unrecognized.
    • The WebUI accepts supported runtime modes regardless of letter case and rejects unsupported mode values.
  • Documentation

    • Clarified that delete is available only at startup and provided the command to run it while the container is active.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: chodeus/BeatsCheck/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 5c74d56c-adc1-4594-b8da-18a54381b71d
📥 Commits

Reviewing files that changed from the base of the PR and between a9a494c and 35899a6.

📒 Files selected for processing: 4
  • app/main.py
  • app/webui.py
  • docs/configuration.md
  • tests/test_runtime_mode.py

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Walkthrough

Runtime configuration reloads now retain the active mode when the saved mode is delete or unrecognized. The WebUI rejects mode updates outside the runtime-switchable modes. The configuration documentation describes these rules and gives a command for running delete.

Changes: Runtime mode handling

Layer / File(s) Summary
Validate modes during config reload
app/main.py, tests/test_runtime_mode.py, docs/configuration.md
_reload_config now accepts saved runtime-switchable modes and keeps the current mode for saved delete or unknown values. Tests cover reload and rescan behavior. The configuration documentation describes the handling of these modes.
Validate WebUI mode updates
app/webui.py, tests/test_runtime_mode.py
The WebUI returns HTTP 400 for mode values outside _RUNTIME_MODES. Tests cover invalid values and case-insensitive acceptance.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 35899

The mode changes appear ready to merge after normal checks.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the required Conventional Commits format and accurately describes the runtime behavior change for saved delete or unknown modes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chodeus

chodeus commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@chodeus
chodeus merged commit a9d19b1 into main Oct 15, 2026
15 checks passed
@chodeus
chodeus deleted the fix/runtime-mode-delete branch October 15, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant