Skip to content

Commit

Permalink
Fix bug in nb_lookup if api_filter contains multiple id (#1042)
Browse files Browse the repository at this point in the history
In the `nb_lookup` plugin, if we provide an `api_filter` containing the `id` field, it will use `.get()` instead of `.filter()`, thus returning the item instead of a list. See PR #376 for more information.

This is fine if you supply only one id. But let's say you want to get a list of items by ids?

For example: `id=1 id=5`

I would expect to get a list of 2 items. But at the moment, it will return the first item only.

This change adds a simple check to see if we're supplying multiple ids.
  • Loading branch information
linkdd authored Dec 10, 2023
1 parent ca2fc6a commit 8cb1149
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/lookup/nb_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def run(self, terms, variables=None, **kwargs):
if netbox_api_filter:
filter = build_filters(netbox_api_filter)

if "id" in filter:
if "id" in filter and len(filter["id"]) == 1:
Display().vvvv(
"Filter is: %s and includes id, will use .get instead of .filter"
% (filter)
Expand Down

0 comments on commit 8cb1149

Please sign in to comment.