fix(client): reject nonpositive wait controls before submitting a task - #84
basil-k-aji-dev wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
`ArtemisClient.run()` awaited `submit()` before `wait_for_task()`, and only the latter validated `timeout` and `poll_interval`. A caller passing a nonpositive value therefore received a `ValueError` with no task handle, while a real server may already have admitted and started the submitted work. `run_task()` delegates to `run()` and inherited the same behaviour. Move both checks into a `_resolve_wait_controls()` helper, called by `wait_for_task()` as before and by `run()` before it submits anything. Valid calls are unchanged: `run()` now resolves the poll interval once and hands the resolved value to `wait_for_task()`. Closes google#83.
69ab5ff to
fb3c502
Compare
|
Thanks for picking up #83! I independently checked |
|
@Chris0Jeky thank you, and sorry for the slow reply. Independent verification on a platform I do not have is worth more than another run of mine on Linux, and you checked the thing that actually matters: zero transport requests on the rejecting path, and a submit on the base before the raise. That is the difference #83 describes, confirmed from outside my own assumptions. Your caveats are the right ones to state. Fake transport rather than a live host means this says the client stops before the call, not that a real Artemis host behaves as expected once it does call; and the full upstream suite is still CI's to run. I have not changed anything since Nothing needed from me unless a maintainer wants something changed. |
Closes #83.
Problem
ArtemisClient.run()awaitssubmit()and only then callswait_for_task(), which is wheretimeoutandpoll_intervalare validated. A caller that passes a nonpositive value therefore gets aValueErrorand no task handle, while a real host may already have admitted and started the submitted task.run_task()delegates torun()and inherited the same behaviour.wait_for_task()called directly already rejects these values without touching the transport, so the contract was inconsistent between the two entry points.Reproduced with the injected transport interface from the issue (no server, device or credentials needed) — on
main:Change
packages/artemis-client/src/artemis_client/client.py_resolve_wait_controls(timeout, poll_interval)holding the two checks thatwait_for_task()already performed, and returning the resolved poll interval.wait_for_task()calls it — same behaviour, same messages.run()calls it beforesubmit(), and passes the resolved interval on towait_for_task()so the value is resolved once rather than twice.No public signature changes. Valid calls are unaffected.
After the change, all four invalid combinations reach the transport zero times:
Tests
packages/artemis-client/tests/test_client.pytest_run_rejects_nonpositive_wait_controls_without_submitting— four subtests (zero/negative for each control) asserting both theValueErrormessage andtransport.calls == [].test_run_task_rejects_nonpositive_wait_controls_without_submitting— the same guarantee through therun_task()entry point named in the issue.test_run_still_submits_and_completes_with_valid_wait_controls— a submit-and-complete run still issues exactlyPOST /api/runthenGET /api/sessions/{id}, so the new early return cannot silently swallow valid calls.The six invalid-input subtests fail on
mainwithAssertionError: Unexpected request: POST /api/runand pass here.Verification
uv run pytest -q packages/artemis-client/testsuv run pytest -q(full deterministic suite)mainon this hostuv run ruff format --check packages/artemis-clientuv run ruff check packages/artemis-clientmake typecheckcould not be run in my environment — thepyrightwheel fetches a Node runtime on first use and my sandbox blocks the download.artemis_clientis insidepyright-core.json, so please let CI confirm that step. The change adds one method with fully annotated parameters and atuple[float, float]return, and removes no annotations.