Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PubSub subscribe must not accept None as topic #3108

Open
davidraker opened this issue Aug 21, 2023 · 0 comments
Open

PubSub subscribe must not accept None as topic #3108

davidraker opened this issue Aug 21, 2023 · 0 comments

Comments

@davidraker
Copy link
Contributor

pubsub.subscribe does not validate that topic is not None. If and when then topic is None, there are circumstances (e.g., pushing the subscriptions to external hosts) where it will crash the platform due to an unhandled exception in the pubsub service.

To Reproduce
Call pubsub.subscribe with None as the topic and external_platforms=True (it may happen if external_platforms==False as well, but I haven't tested this). This results in the untimely death of the process:

2023-08-21 20:47:16,469 () volttron.platform.main ERROR: Unhandled exception in router loop
Traceback (most recent call last):
File "/code/volttron/volttron/platform/main.py", line 842, in zmq_router
service_notifier=notifier).run()
File "/code/volttron/volttron/platform/vip/router.py", line 112, in run
self.poll_sockets()
File "/code/volttron/volttron/platform/main.py", line 512, in poll_sockets
self.route(deserialize_frames(frames))
File "/code/volttron/volttron/platform/vip/router.py", line 308, in route
response = self.handle_subsystem(frames, user_id)
File "/code/volttron/volttron/platform/main.py", line 484, in handle_subsystem
result = self.pubsub.handle_subsystem(frames, user_id)
File "/code/volttron/volttron/platform/vip/pubsubservice.py", line 633, in handle_subsystem
result = self._peer_publish(frames, user_id)
File "/code/volttron/volttron/platform/vip/pubsubservice.py", line 314, in _peer_publish
return self._distribute(frames, user_id)
File "/code/volttron/volttron/platform/vip/pubsubservice.py", line 405, in _distribute
external_count = self._distribute_external(frames)
File "/code/volttron/volttron/platform/vip/pubsubservice.py", line 474, in _distribute_external
if topic.startswith(prefix):
TypeError: startswith first arg must be str or a tuple of str, not NoneType

Expected behavior
A handled exception should be raised and caught when a subscription for the topic None is received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant