TaskResult loses numeric zero turn counts
- Dominant language
- Python
- Stars
- 5.9k
- Forks
- 516
- Avg merge
- 22m
- Merged PRs (30d)
- 5
Description
`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`:
```python
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.
Contributor guide
Research direction
Start with TaskResult.from_payload() in packages/artemis-client/src/artemis_client/models.py and run the reproduction against the three payloads shown in the issue. Add regression coverage for numeric zero, its precedence over current_turn, and compatibility with null, empty, boolean, and string inputs; done means the expected turn values are preserved without a server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100