Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

raise friendly error when pull_subscribe used with invalid stream #499

Closed
tekumara opened this issue Sep 20, 2023 · 2 comments
Closed

raise friendly error when pull_subscribe used with invalid stream #499

tekumara opened this issue Sep 20, 2023 · 2 comments
Labels
defect Suspected defect such as a bug or regression

Comments

@tekumara
Copy link
Contributor

tekumara commented Sep 20, 2023

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/python@3.10/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/python@3.10/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
@tekumara tekumara added the defect Suspected defect such as a bug or regression label Sep 20, 2023
@tekumara
Copy link
Contributor Author

Related to #438

@wallyqs
Copy link
Member

wallyqs commented Feb 23, 2024

Fixed via #512

@wallyqs wallyqs closed this as completed Feb 23, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants