Client run submits a task before rejecting nonpositive wait controls

Open Beginner friendly
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
api

Research direction

Start with the standalone artemis-client implementations of run(), run_task(), and wait_for_task(), following where timeout and poll_interval are validated relative to submit(). Add regression coverage using the injected transport interface to verify invalid controls make no transport calls through both entry points, while valid submit-and-complete behavior remains unchanged.

Written by the indexing model from the issue text.

Description

At 371aa6df56880643da57b30da936e9812fb0ec66, the standalone artemis-client package submits a task before rejecting a nonpositive timeout or poll_interval passed to run(); run_task() inherits the same behavior. The caller receives ValueError without a task handle, although a real server may already have started the submitted work.

run() awaits submit() before calling wait_for_task(), where those arguments are validated. Direct wait_for_task() already rejects them without a transport request. Expected: reuse those checks before task submission, keeping valid calls unchanged.

Credential-free reproduction using the package's injected transport interface (no server or device needed):

import asyncio
from artemis_client import ArtemisClient

class RecordingTransport:
    def __init__(self):
        self.calls = []

    def request(self, method, path, *, json_body=None):
        self.calls.append((method, path))
        return {"status": "started", "tasks": [{
            "session_id": "00000000-0000-4000-8000-000000000123",
            "status": "pending",
        }]}

async def main():
    transport = RecordingTransport()
    client = ArtemisClient("https://artemis.example.test", transport=transport)
    try:
        await client.run("Open Settings", timeout=0)
    except ValueError as error:
        print(type(error).__name__, str(error))
    print(transport.calls)

asyncio.run(main())

Observed with Python 3.12 and the package source on PYTHONPATH:

ValueError timeout must be greater than zero
[('POST', '/api/run')]

Expected transport calls: []. Zero/negative values for both controls reproduce this through both run() and run_task(); a valid submit-and-complete control still succeeds. I have prepared a small fix with regression coverage and am checking contribution requirements before submitting the patch. I found no matching open issue or PR in the current inventory.

Dominant language
Python
Stars
8.2k
Forks
779
Avg merge
20m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/artemis

All issues in google/artemis

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.