Skip to content

fix(server): treat None client results as empty - #189

Open
anderslindho wants to merge 1 commit into
ChannelFinder:masterfrom
anderslindho:fix/find-by-args-none
Open

anderslindho wants to merge 1 commit into
ChannelFinder:masterfrom
anderslindho:fix/find-by-args-none

Conversation

@anderslindho

Copy link
Copy Markdown
Contributor

Committing an IOC could fail with TypeError: 'NoneType' object is not iterable. pyCFClient's findByArgs returns None instead of raising when ChannelFinder answers 404, and the adapter then tried to loop over that None.

ChannelFinder no longer answers an empty search with a 404, so this only happens against an older service, or when a proxy in front of it returns the 404.

getAllProperties has the same problem and is fixed the same way.


Verified with test before and after fix. Closes #73

Committing an IOC could fail with `TypeError: 'NoneType' object is not
iterable`. pyCFClient's `findByArgs` returns `None` instead of raising
when ChannelFinder answers 404, and the adapter then tried to loop over
that `None`.

ChannelFinder no longer answers an empty search with a 404, so this
only happens against an older service, or when a proxy in front of it
returns the 404.

`getAllProperties` has the same problem and is fixed the same way.
@anderslindho anderslindho self-assigned this Nov 17, 2026
@sonarqubecloud

Copy link
Copy Markdown

if self._size_limit > 0:
args = args + [("~size", self._size_limit)]
return [CFChannel.from_dict(ch) for ch in self._client.findByArgs(args)]
return [CFChannel.from_dict(ch) for ch in self._client.findByArgs(args) or []]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit more of a refactor, but might it not be nicer if findByArgs (and the other case below) returned a list instead of list | None?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I agree. But as that requires a change and a release in pyCFClient, maybe merge this first and then do what you suggest?

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

Successfully merging this pull request may close these issues.

Exception: NoneType is not iterable

2 participants