Skip to content

Commit 1aeec37

Browse files
committed
fix: tolerate missing platform unload
wrap platform unload in try/except so ValueError is treated as a successful unload when the sensor platform never finished loading
1 parent a489682 commit 1aeec37

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

custom_components/sharepoint_photos/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,15 @@ async def async_refresh_new_folder(self):
308308

309309
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
310310
"""Handle removal of an entry."""
311-
if unloaded := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
312-
hass.data[DOMAIN].pop(entry.entry_id)
311+
try:
312+
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
313+
except ValueError:
314+
# Platform never finished loading (e.g., setup failed); treat as unloaded.
315+
_LOGGER.debug("Platform %s was never loaded; skipping unload", PLATFORMS)
316+
unloaded = True
317+
318+
if unloaded:
319+
hass.data[DOMAIN].pop(entry.entry_id, None)
313320

314321
return unloaded
315322

0 commit comments

Comments
 (0)