Detect silent failure when Preparing returns to Available#14
Detect silent failure when Preparing returns to Available#14
Conversation
| self._sessions[sn.connector_id] = Session( | ||
| self, | ||
| or_now(sn.timestamp), | ||
| sn.timestamp or datetime.now(timezone.utc).isoformat(), |
There was a problem hiding this comment.
Thanks!
Agreed — using or_now() consistently makes the intent clearer.
I’ve removed the duplicate inline fallback and kept or_now as the single source of truth for timestamps.
| session.ended_silent( | ||
| sn.timestamp or datetime.now(timezone.utc).isoformat(), | ||
|
|
||
| "PREPARING_ABORTED_BEFORE_CHARGING", |
There was a problem hiding this comment.
What is the purpose of this string? Indeed it makes sense for session to hold an enum indicating why session was considered as failed.
There was a problem hiding this comment.
Good point.
For now this is intentionally a string, as Issue #8 focuses only on detecting silent failures, not on formalizing failure classification.
Introducing an enum for failure reasons makes sense and is planned as a follow-up (together with automated tests), but I wanted to keep this change minimal and avoid expanding the scope of this PR.
| @@ -254,6 +273,7 @@ async def handle_status_notification(self, sn: call.StatusNotification): | |||
| session.ended(or_now(sn.timestamp), get_error_code(sn)) | |||
There was a problem hiding this comment.
we call get_error_code by function was removed? Does it work?
There was a problem hiding this comment.
You’re right — the helper was missing after refactoring.
I added get_error_code() locally to this module and verified the faulted flow with runtime tests.
|
All review comments addressed. |
f877b58 to
7f91137
Compare
| from ..engine import Engine | ||
| from typing import cast | ||
|
|
||
| def get_error_code(sn: call.StatusNotification) -> str: |
There was a problem hiding this comment.
Is there any reason to move functions from bottom to top?
Detects silent charging failures where a session enters Preparing
but returns to Available without ever reaching Charging.
Such sessions are now classified as failed and trigger diagnostics,
even though no Faulted status is reported.
Manually verified: