snstac / adsbxcot

Display Aircraft in TAK
https://adsbxcot.rtfd.io
Apache License 2.0
51 stars 14 forks source link

If there's no aircraft returned by a filter, adsbxcot crashes. #10

Closed ampledata closed 2 years ago

ampledata commented 3 years ago

Steps to reproduce:

  1. Set a search area to a place unlikely to have any aircraft flying in it, say where you are within one nautical mile in the middle of the night.

Expected results:

  1. Script will continue to poll and if any aircraft do enter that space, it'll do the adsbxcot thing.

Actual result:

  1. Script raises an Exception.
$ adsbxcot -U udp:127.0.0.1:8087 -A https://adsbexchange.com/api/aircraft/v2/lat/34.4487586/lon/-116.9369205/dist/1/ -X xxx -I 60
2021-08-26 22:31:54,463 pytak INFO - Running EventReceiver
2021-08-26 22:31:54,463 pytak INFO - Running EventWorker
2021-08-26 22:31:54,463 pytak INFO - Running ADSBXWorker with URL 'https://adsbexchange.com/api/aircraft/v2/lat/34.4487586/lon/-116.9369205/dist/1/'
Task completed: <Task finished name='Task-4' coro=<ADSBXWorker.run() done, defined at /Users/gba/Dropbox/Projects/TAK/src/adsbxcot/adsbxcot/classes.py:158> exception=TypeError("object of type 'NoneType' has no len()")>
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-4' coro=<ADSBXWorker.run() done, defined at /Users/gba/Dropbox/Projects/TAK/src/adsbxcot/adsbxcot/classes.py:158> exception=TypeError("object of type 'NoneType' has no len()")>
Traceback (most recent call last):
  File "/Users/gba/Dropbox/Projects/TAK/src/adsbxcot/adsbxcot/classes.py", line 184, in run
    await self._get_adsbx_feed()
  File "/Users/gba/Dropbox/Projects/TAK/src/adsbxcot/adsbxcot/classes.py", line 155, in _get_adsbx_feed
    self._logger.debug("Retrieved %s aircraft", len(aircraft))
TypeError: object of type 'NoneType' has no len()

Culprit:

https://github.com/ampledata/adsbxcot/blob/49718e0f004be040fb2712952464ccec4ba8e19a/adsbxcot/classes.py#L154

We don't check that 'ac' exists before calling len().