Skip to content

Don't raise HomeAssistantError in scanner - #1147

Merged
WillCodeForCats merged 1 commit into
mainfrom
code-quality
Oct 14, 2026
Merged

WillCodeForCats merged 1 commit into
mainfrom
code-quality

Conversation

@WillCodeForCats

@WillCodeForCats WillCodeForCats commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Don't raise HomeAssistantError in scanner. Replace it with ScannerConnectionError.

Summary by CodeRabbit

  • Bug Fixes
    • Improved setup error reporting when a device scanner cannot connect. Connection failures are now shown for the host address, while device-specific scan errors continue to appear with the device selection. This makes it clearer which connection detail needs attention when validating a manually configured device.

@WillCodeForCats WillCodeForCats self-assigned this Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 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: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f2add07-3003-40e2-9a26-154d9fd99494
📥 Commits

Reviewing files that changed from the base of the PR and between 0686a9c and 3afd027.

📒 Files selected for processing: 2
  • custom_components/solaredge_modbus_multi/config_flow.py
  • custom_components/solaredge_modbus_multi/scanner.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The scanner now raises ScannerConnectionError when connection attempts are exhausted. Manual device validation catches this exception as a host error. Device-list error handling remains unchanged.

Changes: Scanner connection error handling

Layer / File(s) Summary
Define, raise, and handle connection errors
custom_components/solaredge_modbus_multi/scanner.py, custom_components/solaredge_modbus_multi/config_flow.py
The scanner defines and raises ScannerConnectionError after connection retries are exhausted. Manual device validation catches it alongside HomeAssistantError in the host-error handler. The scan_device_id documentation names the new exception. Device-list error handling is unchanged.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3afd0

Exhausted connection attempts continue to appear as scan failures or host-validation errors, while device-list errors keep their existing handling. No merge-blocking behavior change is established.

Security architecture risk: ⚪ Minimal · up to 3afd0

The dedicated exception preserves connection-failure reporting in both manual validation and scan-based setup. The inspected change leaves network destinations, validation rules, retries, and cleanup behavior unchanged. No introduced or worsened material security risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated impact is limited to scanner connection-failure propagation and setup error presentation. The inspected comparison does not add network destinations, privileged operations, or consumers that increase independently attackable scope.

Trust Boundaries and Controls

  • inferred — The replacement exception does not create a new route around checked setup: connection exhaustion remains an error, and the inspected manual and scan-based paths do not construct a pending entry from that failure. This preserves the existing failure gate rather than adding a new security control.

Resilience and Maintainability Implications

  • inferred — Failure containment remains compatible with the new exception in both inspected setup paths. Cleanup ownership and retry transitions are unchanged, including their existing limitations under interruption or unsupported concurrent use.
Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: replacing the scanner's use of HomeAssistantError.
Description check Passed The description clearly states the purpose and implementation of the change. It is brief, but the repository template contains guidance rather than required sections, so no critical information is mis…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files.
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

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.

@WillCodeForCats
WillCodeForCats merged commit 204bd9b into main Oct 14, 2026
17 checks passed
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