redis / redis-py

Redis Python client
MIT License
12.62k stars 2.52k forks source link

Bad error message for command xadd if minid argument is a float: "ResponseError: Invalid stream ID specified as stream command argument" #2819

Open ar4hc opened 1 year ago

ar4hc commented 1 year ago

Not an error per se but a big annoyance.

Version: redis = {extras = ["hiredis"], version = "^4.6.0"} (from pyproject) redis server: 7.0.11

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure) MacOS

Description:

If using xadd with minid (for trimming) and the value for minid is a float (doesn't matter the value) like so:

red.xadd("abcdfg", {"123": 123}, minid=0.0)

the error message is

ResponseError: Invalid stream ID specified as stream command argument

which is misleading. A lot...

Can we have a more appropriate error message in that case, please?

ar4hc commented 1 year ago

Perhaps a check in core ?

nFec commented 1 year ago

Tried to provide a patch with https://github.com/nFec/redis-py/tree/patch-1 but cannot follow contribution guideline as dev environment fails to build:

(.venv) till@m1-till redis-py % invoke devenv
Traceback (most recent call last):
  File "/Users/till/code/redis-py/.venv/bin/invoke", line 8, in <module>
    sys.exit(program.run())
             ^^^^^^^^^^^^^
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/program.py", line 373, in run
    self.parse_collection()
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/program.py", line 465, in parse_collection
    self.load_collection()
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/program.py", line 699, in load_collection
    module, parent = loader.load(coll_name)
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/loader.py", line 76, in load
    module = imp.load_module(name, fd, path, desc)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/imp.py", line 235, in load_module
    return load_source(name, filename, file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/imp.py", line 172, in load_source
    module = _load(spec)
             ^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 721, in _load
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/till/code/redis-py/tasks.py", line 11, in <module>
    @task
     ^^^^
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/tasks.py", line 331, in task
    return klass(args[0], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/tasks.py", line 76, in __init__
    self.positional = self.fill_implicit_positionals(positional)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/tasks.py", line 167, in fill_implicit_positionals
    args, spec_dict = self.argspec(self.body)
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/till/code/redis-py/.venv/lib/python3.11/site-packages/invoke/tasks.py", line 153, in argspec
    spec = inspect.getargspec(func)
           ^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

As it is hopefully only minimal work for anyone with a working dev environment, I will not spend more time on this. We already hunted this problem for more time than I'd care to admit ;)

ar4hc commented 1 year ago

And reading the error message more carefully would've helped too... But ... benefit of hindsight etc. Its "Stream ID" as in ID of an element in the stream, not the ID/name of the stream. So the wording of the error message can be confusing.

github-actions[bot] commented 3 months ago

This issue is marked stale. It will be closed in 30 days if it is not updated.