You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clear the in-flight placeholder on any error in openplantbook.get - #119
openplantbook.get removes its in-flight placeholder in a finally whenever the fetch did not finish: on any error or cancellation, not only the three it handles.
Before, an unexpected error (a network error, for example) left the placeholder behind, so every later request for that species waited 10 seconds and failed until the integration was reloaded.
An error the service did not expect left the placeholder in the cache, so
every later request for that species waited on it and failed until the
integration was reloaded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This PR updates openplantbook.get to clear in-flight placeholders after unexpected errors or cancellation, allowing later requests for the same species to retry.
Changes:
Move failed-fetch cleanup into a finally block.
Add a regression test confirming a request succeeds after an unexpected network error.
File
Description
tests/test_init.py
Tests recovery after an unexpected API error.
custom_components/openplantbook/__init__.py
Centralizes placeholder cleanup for unsuccessful fetches.
An unload during the API call replaces the species cache; popping from the
original one neither raises nor touches a newer request's entry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A cancellation regression test is still missing to verify that cancellation propagates, the placeholder is removed, and a subsequent request succeeds.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Add a regression test for cancellation cleanup and retry
custom_components/openplantbook/__init__.py:271
Please add a cancellation regression test alongside the new ConnectionError test: cancel a request while the mocked API call is pending, verify that cancellation propagates and the placeholder is removed, then verify that a subsequent request succeeds. The current test does not protect the cancellation behavior explicitly promised by this change; it would also pass with cleanup that catches only Exception, which excludes asyncio.CancelledError.
The test from the last review summary is added in a5bacb6: test_get_plant_works_again_after_a_cancelled_request cancels a request while the API call is pending, checks that the cancellation propagates, and that the next request for the same species succeeds. It fails when the cleanup catches only Exception (checked), while the network-error test still passes then.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
openplantbook.getremoves its in-flight placeholder in afinallywhenever the fetch did not finish: on any error or cancellation, not only the three it handles.Before, an unexpected error (a network error, for example) left the placeholder behind, so every later request for that species waited 10 seconds and failed until the integration was reloaded.
🤖 Generated with Claude Code