Skip to content

fix(remote_services): immediate result codes were collapsed to UNKNOWN - #92

Merged
fredriklj merged 3 commits into
CJNE:mainfrom
bartolije:fix-rs-immediate-result
Aug 29, 2026
Merged

fix(remote_services): immediate result codes were collapsed to UNKNOWN#92
fredriklj merged 3 commits into
CJNE:mainfrom
bartolije:fix-rs-immediate-result

Conversation

@bartolije

Copy link
Copy Markdown

When _send_command got a terminal result with no status_id, it called RemoteServiceStatus(result_code) with a bare string ("PERFORMED", "ERROR", ...). The constructor then ran if "status" in response: on that string — a string-in-string check that is False for these codes — so state silently fell through to ExecutionState.UNKNOWN. Callers had no way to distinguish a successful remote action from a server timeout.

Two changes:

  1. _send_command (remote_services.py:299): wrap the bare code in the same dict shape the polling endpoint returns so the constructor extracts it through the existing path:

    RemoteServiceStatus({"status": {"result": result_code}})
    
  2. RemoteServiceStatus.__init__: guard with isinstance(response, dict) and tolerate result codes outside the ExecutionState enum (e.g. a future "REJECTED") with a try/except ValueError — falling back to UNKNOWN instead of crashing during construction.

Concrete repro (no test infra needed):

>>> from pyporscheconnectapi.remote_services import (
...     RemoteServiceStatus, ExecutionState,
... )
>>> # Before this patch: silent UNKNOWN.
>>> # After:
>>> s = RemoteServiceStatus({"status": {"result": "PERFORMED"}})
>>> s.state == ExecutionState.PERFORMED
True

Jeremie and others added 3 commits May 16, 2026 14:28
When `_send_command` got a terminal result with no `status_id`, it
called `RemoteServiceStatus(result_code)` with a bare string
("PERFORMED", "ERROR", ...). The constructor then ran
`if "status" in response:` on that string — a string-in-string check
that is False for these codes — so `state` silently fell through to
ExecutionState.UNKNOWN. Callers had no way to distinguish a successful
remote action from a server timeout.

Two changes:

1. `_send_command` (`remote_services.py:299`): wrap the bare code in the
   same dict shape the polling endpoint returns so the constructor
   extracts it through the existing path:

       RemoteServiceStatus({"status": {"result": result_code}})

2. `RemoteServiceStatus.__init__`: guard with `isinstance(response, dict)`
   and tolerate result codes outside the ExecutionState enum (e.g. a
   future "REJECTED") with a try/except ValueError — falling back to
   UNKNOWN instead of crashing during construction.

Concrete repro (no test infra needed):

    >>> from pyporscheconnectapi.remote_services import (
    ...     RemoteServiceStatus, ExecutionState,
    ... )
    >>> # Before this patch: silent UNKNOWN.
    >>> # After:
    >>> s = RemoteServiceStatus({"status": {"result": "PERFORMED"}})
    >>> s.state == ExecutionState.PERFORMED
    True

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removed comments clarifying response structure and error handling.
Removed comments explaining result handling for immediate results.
@fredriklj
fredriklj merged commit 0be06ed into CJNE:main Aug 29, 2026
1 check failed
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.

2 participants