Skip to content

Commit 8cb1149

Browse files
authored
Fix bug in nb_lookup if api_filter contains multiple id (#1042)
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.
1 parent ca2fc6a commit 8cb1149

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plugins/lookup/nb_lookup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def run(self, terms, variables=None, **kwargs):
440440
if netbox_api_filter:
441441
filter = build_filters(netbox_api_filter)
442442

443-
if "id" in filter:
443+
if "id" in filter and len(filter["id"]) == 1:
444444
Display().vvvv(
445445
"Filter is: %s and includes id, will use .get instead of .filter"
446446
% (filter)

0 commit comments

Comments
 (0)