Repository navigation
fix(python-sdk): validate ask() question and limit before signing (WALM-858) - #1255
harrymove-ctrl wants to merge 2 commits into
Conversation
|
@ducnmm when you have time, could you review this? Tracked in WALM-858, CI is green. |
ducnmm
left a comment
There was a problem hiding this comment.
[P2] Include the Python release update with this SDK change.
The branch still carries Python 0.1.11, while current dev and main both carry 0.1.12 and that version is already on PyPI. This PR does not prepare a new release. After rebasing, keeping 0.1.12 makes release-python-sdk.yml skip stable publication, so users cannot receive this fix. Please prepare the next patch (currently 0.1.13), synchronize pyproject.toml, memwal/__init__.py, the package and docs changelogs, and the verifier pin. Re-evaluate the version if another unreleased patch lands first; use the manual release path.
Validation: 263 non-integration Python tests passed; Ruff clean. No new runtime regression found.
ask() was the only text-taking method without the blank-text check, so an empty question reached the LLM-backed /api/ask endpoint, and its limit was forwarded verbatim (NaN serialized as a bare, invalid-JSON NaN token; negative and fractional values sent as-is). Reject a blank question and any limit that is not a positive int. Fixes #1249
The branch carried 0.1.11 and dev carries 0.1.12, which is already on PyPI, so release-python-sdk.yml would skip stable publication of this fix. Bump the Python SDK to 0.1.13 in pyproject.toml and memwal/__init__.py, add the 0.1.13 entry to the package and docs changelogs, and move the manual release verifier's Python pin to 0.1.13.
6d5162e to
213b96b
Compare
|
@ducnmm rebased on dev and prepared Python 0.1.13 (pyproject, |
Summary
ask()was the only text-taking method in the Python client that skipped_reject_blank_text. An empty question went to the LLM-backed/api/askendpoint. Itslimitwas also sent as given:float("nan")was written as a bareNaNtoken (not valid JSON), and-1and2.5were sent unchanged.Changes
ask()rejects a blank question withValueError("question cannot be empty")._require_positive_inthelper:limitmust be anintgreater than 0, andboolis rejected. Otherwise it raisesValueError("limit must be a positive integer, got ..."). Both checks run before signing.Tests
tests/test_ask_validation.py: blank questions and limits of NaN, inf, -1, 0, 2.5,"5",TrueandNoneare rejected with nothing sent. A valid call goes out unchanged.ruff check memwal/ tests/andpytest tests/ -m "not integration"pass.Estimate: 1 SP (incl. review)
Local results: ruff clean; pytest -m "not integration": 263 passed (new test failed 11/12 before the fix); mypy unchanged vs dev.
Linear: WALM-858
Fixes #1249