Skip to content

TaskResult loses numeric zero turn counts #103

Description

@Chris0Jeky

TaskResult.from_payload() sets result.turns to None for numeric turns=0,
or uses current_turn if that alias is present. String "0" is already preserved.

Reproduced on 371aa6df56880643da57b30da936e9812fb0ec66, Python 3.12.14, using
packages/artemis-client/src on PYTHONPATH:

from artemis_client import TaskResult

for fields in ({"turns": 0}, {"turns": 0, "current_turn": 7}, {"turns": "0"}):
    print(TaskResult.from_payload({"task_id": "sample", **fields}).turns)
# Actual:   None, 7, 0
# Expected: 0,    0, 0

The selection in packages/artemis-client/src/artemis_client/models.py uses
payload.get("turns") or payload.get("current_turn"), so zero triggers the
fallback before integer conversion.

I propose preserving numeric zero and its precedence over the legacy alias,
while keeping the existing handling of null, empty and boolean values. The fix
can stay within the parser, with regression tests for zero and compatibility
checks for the other inputs. This reproduces directly in the client model without
a server.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions