Skip to content

fix(startup): bound repeated transport failures - #323

Merged
eXPerience83 merged 2 commits into
mainfrom
fix/322-bound-startup-transport-failures
Aug 16, 2026
Merged

fix(startup): bound repeated transport failures#323
eXPerience83 merged 2 commits into
mainfrom
fix/322-bound-startup-transport-failures

Conversation

@eXPerience83

@eXPerience83 eXPerience83 commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • classify only exhausted timeout and aiohttp transport failures with an internal PollenTransportError
  • defer parent setup to Home Assistant after two consecutive transport setup failures
  • preserve reset, invalid-location, cancellation, redaction, sibling, and non-transport behavior with focused regression coverage

Fixes #322.

Scope

Runtime changes are limited to custom_components/pollenlevels/client.py and custom_components/pollenlevels/__init__.py. Tests are limited to tests/test_client.py, tests/test_init.py, and tests/test_ha_init.py. Migration, identity, dependencies, CI, documentation, and release metadata are unchanged.

The known two-consecutive-transport-failures tradeoff, including possible deferral of a later healthy sibling, was explicitly reviewed and approved in #322.

Validation

Summary by CodeRabbit

  • Bug Fixes
    • Improved recovery from temporary network and timeout issues during setup.
    • Setup now retries transient connection failures and stops cleanly after repeated failures.
    • Successful refreshes and non-network errors no longer incorrectly contribute to connection-failure limits.
    • Improved cancellation handling so interrupted setup and retry operations clean up correctly.
    • Preserved clearer handling for invalid locations and retryable service responses.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eb9052ab-2d9d-4fe9-b921-6f95efd6dd7f

📥 Commits

Reviewing files that changed from the base of the PR and between 67d2710 and 1de26db.

📒 Files selected for processing (2)
  • tests/test_ha_init.py
  • tests/test_init.py

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The client now raises PollenTransportError after exhausted timeout or network retries. Parent setup counts consecutive transport failures and defers after two. Tests cover sequential setup, cancellation, sibling isolation, independent entries, cleanup, retry, and recovery.

Changes

Transport failure classification and retry behavior

Layer / File(s) Summary
Transport error classification
custom_components/pollenlevels/client.py, tests/test_client.py
Exhausted timeout and network retries now raise PollenTransportError. Tests verify retry counts, backoff, redaction, cancellation, and HTTP error classification.
Parent transport failure accounting
custom_components/pollenlevels/__init__.py, tests/test_init.py
Parent setup counts consecutive transport failures, resets the count for successful or non-transport outcomes, and raises a parent-level ConfigEntryNotReady after two failures. Tests cover sequential refreshes, cancellation, invalid locations, sibling isolation, and failure resets.
Home Assistant lifecycle validation
tests/test_ha_init.py
Integration tests cover setup cleanup, independent parent loading, deferred setup retry, and recovery to LOADED without premature entity creation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 1de26

The PR bounds repeated transport failures while preserving the documented behaviors, and no actionable merge-blocking risk remains after the reported checks.

Sequence Diagram(s)

sequenceDiagram
  participant HomeAssistant
  participant ParentSetup
  participant GooglePollenApiClient
  HomeAssistant->>ParentSetup: start parent setup
  ParentSetup->>GooglePollenApiClient: refresh location
  GooglePollenApiClient-->>ParentSetup: exhausted transport failure
  ParentSetup->>ParentSetup: count consecutive failure
  ParentSetup-->>HomeAssistant: ConfigEntryNotReady after threshold
  HomeAssistant-->>ParentSetup: scheduled setup retry
  ParentSetup->>GooglePollenApiClient: refresh after recovery
  GooglePollenApiClient-->>ParentSetup: successful refresh
  ParentSetup-->>HomeAssistant: setup loaded
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The threshold bounds startup delay, but two location-specific transport failures can skip a later healthy sibling without strong shared-outage evidence required by issue #322. Use a mitigation that distinguishes shared outages from isolated location failures, or provide strong evidence that the threshold preserves healthy-sibling initialization.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes are limited to client transport classification, integration startup handling, and related tests, which match issue #322.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: limiting repeated transport failures during startup.

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.

@eXPerience83

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 623c42d6-4d40-4f2e-8633-d49accbcba0b

📥 Commits

Reviewing files that changed from the base of the PR and between 866ebe2 and 67d2710.

📒 Files selected for processing (5)
  • custom_components/pollenlevels/__init__.py
  • custom_components/pollenlevels/client.py
  • tests/test_client.py
  • tests/test_ha_init.py
  • tests/test_init.py

Comment thread tests/test_ha_init.py Outdated
Comment thread tests/test_ha_init.py Outdated
Comment thread tests/test_init.py Outdated
@eXPerience83

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@eXPerience83
eXPerience83 marked this pull request as ready for review August 16, 2026 05:38
@eXPerience83
eXPerience83 merged commit 50e30ee into main Aug 16, 2026
11 checks passed
@eXPerience83
eXPerience83 deleted the fix/322-bound-startup-transport-failures branch August 16, 2026 05:45
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.

fix: bound startup delay during repeated transport failures

1 participant