Skip to content

findByArg should return an iterable, not NoneType #27

@simon-ess

Description

@simon-ess

In https://github.com/ChannelFinder/pyCFClient/blob/9689d5bf/channelfinder/ChannelFinderClient.py#L334 we have that findByArgs returns None if the client gets a 404. However, in cfstore.py from recsync, we have

        for ch in client.findByArgs(prepareFindArgs(conf, [('~name', eachSearchString)])):
            existingChannels[ch["name"]] = ch

which results in repeated errors such as

2023-08-24T11:47:19+0000 [-] ERROR:recceiver.cfstore CF_COMMIT FAILURE: [Failure instance: Traceback: <class 'TypeError'>: 'NoneType' object is not iterable
	/usr/local/lib/python3.10/threading.py:1016:_bootstrap_inner
	/usr/local/lib/python3.10/threading.py:953:run
	/home/recceiver/venv/lib/python3.10/site-packages/twisted/_threads/_threadworker.py:47:work
	/home/recceiver/venv/lib/python3.10/site-packages/twisted/_threads/_team.py:182:doWork
	--- <exception caught here> ---
	/home/recceiver/venv/lib/python3.10/site-packages/twisted/python/threadpool.py:244:inContext
	/home/recceiver/venv/lib/python3.10/site-packages/twisted/python/threadpool.py:260:<lambda>
	/home/recceiver/venv/lib/python3.10/site-packages/twisted/python/context.py:117:callWithContext
	/home/recceiver/venv/lib/python3.10/site-packages/twisted/python/context.py:82:callWithContext
	/home/recceiver/venv/lib/python3.10/site-packages/recceiver/cfstore.py:275:_commitWithThread
	/home/recceiver/venv/lib/python3.10/site-packages/recceiver/cfstore.py:558:poll
	/home/recceiver/venv/lib/python3.10/site-packages/recceiver/cfstore.py:464:__updateCF__
	]

in the log. It would be better to return an empty list or some other empty iterable, or to even raise an exception to avoid this junk log data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions