Skip to content

Conversation

@ingoratsdorf
Copy link
Contributor

@ingoratsdorf ingoratsdorf commented Sep 27, 2025

Against stray folders, leftover artefacts and missing configs

Ref issue: #1187

Summary by CodeRabbit

  • Bug Fixes
    • Improved plugin loading resilience: if a plugin’s config.json is missing or invalid, it is skipped and an error is logged, preventing startup failures.
    • Unexpected errors during plugin config parsing are caught and logged, ensuring remaining plugins still load.
    • Maintains previous behavior for determining which plugins to load; valid plugin configurations are still loaded and sorted as before.

Against stray folders, leftover artefacts and missing configs
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 27, 2025

Walkthrough

The plugin configuration loader in server/plugin_utils.py now wraps per-plugin config.json parsing in try/except. On FileNotFoundError, JSONDecodeError, or other Exceptions, it logs the error and skips that plugin. The selection logic for which plugins to consider and the final sorting/return behavior remain the same.

Changes

Cohort / File(s) Summary of Changes
Plugin config loading error handling
server/plugin_utils.py
Added try/except around config.json parsing in get_plugins_configs. On FileNotFoundError or JSONDecodeError, log and skip the plugin; added catch-all Exception logging. Preserved existing plugin selection and return ordering logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant S as Server
  participant PU as PluginUtils.get_plugins_configs
  participant FS as FileSystem
  participant J as JSON Parser
  participant L as Logger

  S->>PU: get_plugins_configs()
  loop For each candidate plugin
    PU->>FS: Read plugin/config.json
    alt File present
      FS-->>PU: File contents
      PU->>J: Parse JSON
      alt JSON valid
        J-->>PU: Config object
        PU-->>PU: Append to pluginsList
      else JSONDecodeError
        J-->>PU: Error
        PU->>L: Log JSON decode error
        PU-->>PU: Skip plugin
      end
    else FileNotFoundError
      FS-->>PU: Error
      PU->>L: Log missing config
      PU-->>PU: Skip plugin
    end
    opt Unexpected exception
      PU->>L: Log unexpected error
      PU-->>PU: Skip plugin
    end
  end
  PU-->>S: Sorted pluginsList
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hopped through configs, nimble and bright,
When files go missing, I don’t take fright.
If JSON is tangled, I log, then I glide—
Skipping the snares with a whiskered pride.
Now plugins align, neat as a row—
Onward I bound, ready to go! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Make plugin loader more robust" accurately captures the primary focus of the changes, which improve error handling and resilience in the plugin loading process by adding exception handling for missing or malformed configs. It is concise, specific to the main change, and clearly conveys the intent to a reviewer scanning the PR history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c8fa55 and 5395524.

📒 Files selected for processing (1)
  • server/plugin_utils.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{server/**/*.py,front/plugins/*/*.py}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

{server/**/*.py,front/plugins/*/*.py}: Never hardcode ports or secrets; define settings once (core ccd() or plugin manifest) and read via get_setting_value() everywhere
Use logger.mylog(level, [message]) with levels none/minimal/verbose/debug/trace; keep verbose output concise unless debugging
Reuse helpers in helper.py (timeNowTZ, normalize_mac, sanitizers) and prefer server/db/db_helper.py over raw SQL in new paths

Files:

  • server/plugin_utils.py
🧬 Code graph analysis (1)
server/plugin_utils.py (2)
server/helper.py (1)
  • get_file_content (255-261)
server/logger.py (1)
  • mylog (86-89)
🪛 Ruff (0.13.1)
server/plugin_utils.py

219-219: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


222-222: Do not catch blind exception: Exception

(BLE001)


223-223: Use explicit conversion flag

Replace with conversion flag

(RUF010)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: docker_dev

@jokob-sk jokob-sk merged commit d9feddd into netalertx:main Sep 27, 2025
4 checks passed
@ingoratsdorf ingoratsdorf deleted the pluginloader-fix branch September 28, 2025 02:34
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.

2 participants