Follow-up/blocker discovered during the live runtime validation of Issue #53 on exact merged develop SHA 3f458b3906ce2c1db13ea982f2488418978ef0d3.
Runtime result from Issue #53:
initial:
server_history_ready=false
server_history_source=local_fallback
server_history_reason=upstream_vehicle_unavailable
later reacquisition:
server_history_ready=false
server_history_source=local_fallback
server_history_reason=sync_failed
server_history_capability=authenticated_trips_transport
server_history_error=Connector is closed.
The reacquisition worker therefore did what #53 intended: it later resolved a VIN-matching loaded upstream client/vehicle and reached the authenticated historical transport. The remaining blocker is that the resolved upstream HTTP transport was not usable at request time.
Relevant upstream lifecycle code at inspected upstream commit 950cc93074c7a43974956a3134579e2cbc81228d:
StellantisBase.start_session() creates a new aiohttp.ClientSession() only when self._session is falsey;
close_session() returns immediately when self._session.closed is already true and in that early-return path does not reset self._session = None;
make_http_request() catches request failures and calls close_session();
- normal upstream config-entry shutdown also closes the shared session.
This makes a stranded closed-session/closed-connector reference a plausible cause, but it is NOT yet proven. A concurrent upstream request closing the shared session, a stale/shutting-down runtime client, or another lifecycle race must also be ruled out.
Required audit first
On the current HA runtime, without modifying source or stores, reproduce/inspect the failure and capture for the exact client object that SV resolves:
- upstream ConfigEntry id, loaded state and
runtime_data object identity;
- exact VIN and coordinator identity returned by
async_get_coordinator_by_vin(vin);
client._shutting_down if present;
client._session identity and whether it is None;
client._session.closed when present;
- connector identity and
connector.closed when present;
- whether a normal upstream coordinator/API refresh immediately before/after the SV history attempt succeeds or fails;
- whether the resolved
runtime_data object changes across reload/reacquisition;
- exact exception type/traceback for
Connector is closed. rather than only the message.
Do not expose tokens/credentials in the report.
Fix constraints
After the root cause is proven, implement the smallest SV-side compatibility fix. Keep the Stellantis Vehicles repository unchanged.
Architecture constraints:
- exact VIN matching remains mandatory;
- no independent OAuth/login/credential stack;
- do not monkey-patch upstream methods/classes;
- do not silently bind to a stale or shutting-down client;
- prefer the currently loaded
ConfigEntry.runtime_data object;
- preserve local/archive fallback until an authenticated
/trips sync actually succeeds;
- transient transport/session lifecycle failures must remain recoverable in the same HA uptime and must not permanently strand server history in
sync_failed;
- do not clear/archive raw history on failure.
If the proven cause is a closed/stale upstream session object, the implementation must explicitly document why the chosen SV compatibility action is safe and narrowly scoped. Do not introduce a second long-lived HTTP session owned by SV without an explicit architecture review.
Regression tests
Cover the proven failure mode, including:
- resolved client with unusable/closed transport;
- later recovery to a usable authenticated transport;
- strict VIN matching;
- no duplicate retry loops;
- unload cancellation;
- archive/local fallback preservation;
- readiness only after successful sync.
Issue #53 remains open until this blocker is fixed and the same runtime acceptance reaches server_history_ready=true, source=server, reason=sync_succeeded with a fresh last_sync.
No main promotion or release before runtime validation.
Follow-up/blocker discovered during the live runtime validation of Issue #53 on exact merged
developSHA3f458b3906ce2c1db13ea982f2488418978ef0d3.Runtime result from Issue #53:
The reacquisition worker therefore did what #53 intended: it later resolved a VIN-matching loaded upstream client/vehicle and reached the authenticated historical transport. The remaining blocker is that the resolved upstream HTTP transport was not usable at request time.
Relevant upstream lifecycle code at inspected upstream commit
950cc93074c7a43974956a3134579e2cbc81228d:StellantisBase.start_session()creates a newaiohttp.ClientSession()only whenself._sessionis falsey;close_session()returns immediately whenself._session.closedis already true and in that early-return path does not resetself._session = None;make_http_request()catches request failures and callsclose_session();This makes a stranded closed-session/closed-connector reference a plausible cause, but it is NOT yet proven. A concurrent upstream request closing the shared session, a stale/shutting-down runtime client, or another lifecycle race must also be ruled out.
Required audit first
On the current HA runtime, without modifying source or stores, reproduce/inspect the failure and capture for the exact client object that SV resolves:
runtime_dataobject identity;async_get_coordinator_by_vin(vin);client._shutting_downif present;client._sessionidentity and whether it isNone;client._session.closedwhen present;connector.closedwhen present;runtime_dataobject changes across reload/reacquisition;Connector is closed.rather than only the message.Do not expose tokens/credentials in the report.
Fix constraints
After the root cause is proven, implement the smallest SV-side compatibility fix. Keep the Stellantis Vehicles repository unchanged.
Architecture constraints:
ConfigEntry.runtime_dataobject;/tripssync actually succeeds;sync_failed;If the proven cause is a closed/stale upstream session object, the implementation must explicitly document why the chosen SV compatibility action is safe and narrowly scoped. Do not introduce a second long-lived HTTP session owned by SV without an explicit architecture review.
Regression tests
Cover the proven failure mode, including:
Issue #53 remains open until this blocker is fixed and the same runtime acceptance reaches
server_history_ready=true,source=server,reason=sync_succeededwith a freshlast_sync.No
mainpromotion or release before runtime validation.