Skip to content

raise friendly error when pull_subscribe used with invalid stream #499

Closed
@tekumara

Description

@tekumara

What version were you using?

2.4.0

What environment was the server running in?

n/a

Is this defect reproducible?

import asyncio
import nats

async def main():
    async def error_handler(e):
        print("Error:", e, type(e))

    nc = await nats.connect(error_cb=error_handler)
    js = nc.jetstream()

    # Create pull based consumer
    psub = await js.pull_subscribe("foobar", "psub")

    await nc.close()

if __name__ == "__main__":
    asyncio.run(main())

Given the capability you are leveraging, describe your expectation?

A self-descriptive helpful error message

Given the expectation, what is the defect you are observing?

    asyncio.run(main())
  File "/opt/homebrew/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Cellar/[email protected]/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/tekumara/code/nats-demo/src/demo/durable_watch.py", line 38, in main
    psub = await js.pull_subscribe("foobar", "psub")
  File "/Users/tekumara/code/nats-demo/.venv/lib/python3.10/site-packages/nats/js/client.py", line 410, in pull_subscribe
    stream = await self._jsm.find_stream_name_by_subject(subject)
  File "/Users/tekumara/code/nats-demo/.venv/lib/python3.10/site-packages/nats/js/manager.py", line 65, in find_stream_name_by_subject
    return info['streams'][0]
TypeError: 'NoneType' object is not subscriptable

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSuspected defect such as a bug or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions