Skip to content

fix: do not fail config entry setup silently - #131

Closed
lstachowiak wants to merge 1 commit into
CyberDeer:masterfrom
lstachowiak:fix/silent-config-entry-setup-failures
Closed

lstachowiak wants to merge 1 commit into
CyberDeer:masterfrom
lstachowiak:fix/silent-config-entry-setup-failures

Conversation

@lstachowiak

Copy link
Copy Markdown

async_setup_entry returned False when parcel locker data was missing from the config entry or when the parcel locker ID could not be scraped from inpost.pl. Home Assistant turns that into ConfigEntryState.SETUP_ERROR with reason "Unknown error", logs nothing at all and schedules no retry, so the integration stayed dead until the next restart or manual reload.

Both cases now raise a proper exception: ConfigEntryError for broken entry data and ConfigEntryNotReady for problems on InPost side, so the reason is logged and transient failures are retried.

The parcel locker page URL is built from data stored when the integration was configured. InPost redirects outdated URLs to /znajdz-paczkomat with HTTP 200, which silently produced no regex match - such a redirect is now detected, reported and the parcel locker data is refetched and saved back to the config entry before giving up.

Additionally:

  • read the response body inside the request timeout - session.request() returns as soon as the headers arrive, so a stalled body left the setup hanging for aiohttp's default five minutes without any log entry
  • log a warning whenever a request fails or the air data cannot be found
  • report missing air sensors as ConfigEntryError from the coordinator instead of matching the exception message against a string
  • store parcel locker data in the config entry as a plain dict
  • cover async_setup_entry with tests

async_setup_entry returned False when parcel locker data was missing from
the config entry or when the parcel locker ID could not be scraped from
inpost.pl. Home Assistant turns that into ConfigEntryState.SETUP_ERROR
with reason "Unknown error", logs nothing at all and schedules no retry,
so the integration stayed dead until the next restart or manual reload.

Both cases now raise a proper exception: ConfigEntryError for broken entry
data and ConfigEntryNotReady for problems on InPost side, so the reason is
logged and transient failures are retried.

The parcel locker page URL is built from data stored when the integration
was configured. InPost redirects outdated URLs to /znajdz-paczkomat with
HTTP 200, which silently produced no regex match - such a redirect is now
detected, reported and the parcel locker data is refetched and saved back
to the config entry before giving up.

Additionally:

- read the response body inside the request timeout - session.request()
  returns as soon as the headers arrive, so a stalled body left the setup
  hanging for aiohttp's default five minutes without any log entry
- log a warning whenever a request fails or the air data cannot be found
- report missing air sensors as ConfigEntryError from the coordinator
  instead of matching the exception message against a string
- store parcel locker data in the config entry as a plain dict
- cover async_setup_entry with tests
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