Bug #19707
Searching for specific organizations/locations broken
Description
If I try to search through subnets with location_id every subnet is returned as long as the location_id actually exists. If I search for a nonexsitent location_id no subnet gets returned.
Also searching for organizations seems to be broken too, because when I enter a location name as organization I get a list of all subnets.
Examples:
Subnet1:
name: net1-mgmt
location_id: 8
Subnet2:
name: net2-mgmt
location_id: 9
search_string: location_id = 9 and name ~ net%-mgmt
Result: Both Subnets
Expected Result: Subnet2
search_string: location_id = 90 and name ~ net%-mgmt
Result: Nothing
Expected Result: Nothing (this is actually correct)
search_string: organization_id = 9 and name ~ net%-mgmt
Result: Both Subnets
Expected Result: Nothing as organization_id 9 does not exist
Related issues
Associated revisions
Refs #19707 - test searching domains with locs
(cherry picked from commit 114973b3525a60ca2649977ffde389229d5a0157)
Refs #19707 - test searching domains with locs
(cherry picked from commit 114973b3525a60ca2649977ffde389229d5a0157)
History
#1
Updated by Anonymous about 5 years ago
Somebody on IRC had the same problem with an API call for getting a list of proxies per location. This worked in 1.14: '/api/smart_proxies?search=feature=TFTP+and+location=xxx'
#2
Updated by Anonymous about 5 years ago
- Subject changed from Searching subnets for specific location_id to Searching for specific organizations/locations broken
- Category changed from Search to Organizations and Locations
#3
Updated by Daniel Lobato Garcia about 5 years ago
I'm currently not able to reproduce this neither the comment by mmoll, I'll try later with exactly the same setup as described in the issue.
#4
Updated by Anonymous about 5 years ago
- File proxies.png proxies.png added
See the attached picture for my proxies. geode.kvedulv.de is only in the location "Home", but still is showing up in the search results via API:
mmoll@sledge:/tmp$ http --verify=no --auth mmoll:xxx 'https://sledge.kvedulv.de/api/smart_proxies?search=location=GCSC2' [...] { "page": 1, "per_page": 20, "results": [ { "created_at": "2017-02-25 21:35:42 UTC", "features": [ { "id": 4, "name": "DHCP" }, { "id": 16, "name": "Logs" } ], "id": 3, "name": "geode.kvedulv.de", "updated_at": "2017-02-25 21:35:42 UTC", "url": "https://geode.kvedulv.de:8443" }, { "created_at": "2015-04-10 11:19:19 UTC", "features": [ { "id": 6, "name": "Puppet CA" }, { "id": 5, "name": "Puppet" }, { "id": 14, "name": "Dynflow" }, { "id": 15, "name": "SSH" }, { "id": 16, "name": "Logs" }, { "id": 2, "name": "TFTP" } ], "id": 1, "name": "sledge.kvedulv.de", "updated_at": "2016-09-14 18:25:54 UTC", "url": "https://sledge.kvedulv.de:8443" } ], "search": "location=GCSC2", "sort": { "by": null, "order": null }, "subtotal": 2, "total": 2 }
#5
Updated by Marek Hulán about 5 years ago
I can reproduce as well. It's not specific to API. I put some reproducing and debugging info here - https://gist.github.com/ares/6c5dc51581e20805b7798212960bc108
#6
Updated by Christian Schulze-Wiehenbrauk about 5 years ago
Marek Hulán wrote:
I can reproduce as well. It's not specific to API. I put some reproducing and debugging info here - https://gist.github.com/ares/6c5dc51581e20805b7798212960bc108
I had a look at the sql statement and it seems that a filter is missing for the sub select: taxable_taxonomies.type = $1 resp. taxonomies.type = $2. This leads to a erroneous result set, containing ids that have the wrong taxable_taxonomies.type.
#7
Updated by Christian Schulze-Wiehenbrauk about 5 years ago
EDIT: further explanation here: https://gist.github.com/Ntr0/922a52b11476cde4ed256069c06684a1
To reproduce this bug in unit tests different taxable_taxonomy types must have the same ID and the same taxonomy_id.
#8
Updated by Christian Schulze-Wiehenbrauk about 5 years ago
Not sure how to contribute this besides a gist,
so here is the unit test:
https://gist.github.com/Ntr0/94c2bd1350253db0620933d297473b86
#9
Updated by Jitendra Yejare almost 5 years ago
- Bugzilla link set to 1472863
#10
Updated by Tomáš Strachota almost 5 years ago
There's a similar issue with filtering hosts by hostgroups: http://projects.theforeman.org/issues/20204 Could be a dupe.
#11
Updated by Tomáš Strachota almost 5 years ago
Disregard my previous comment, it's a different bug.
#12
Updated by Marek Hulán almost 5 years ago
- Target version set to 1.17.0-RC2
#13
Updated by Marek Hulán almost 5 years ago
- Target version changed from 1.17.0-RC2 to 1.18.0-RC2
#14
Updated by Ondřej Pražák almost 5 years ago
- Assignee set to Ondřej Pražák
#15
Updated by Marek Hulán almost 5 years ago
- Target version changed from 1.18.0-RC2 to 214
#16
Updated by Marek Hulán almost 5 years ago
Fixed in scoped_search 4.1.1 but that introduced another regression so we ended up using 4.1.2.
#17
Updated by Marek Hulán almost 5 years ago
- Related to Bug #20867: Scoped search 4.1.1 introduces a regression and breaks tests added
#18
Updated by Marek Hulán almost 5 years ago
- Related to Bug #20872: Update scoped_search to 4.1.2 or higher added
#19
Updated by Marek Hulán almost 5 years ago
- Status changed from New to Closed
- Legacy Backlogs Release (now unused) set to 296
This has been addressed by #20872
#20
Updated by Marek Hulán almost 5 years ago
- Pull request https://github.com/theforeman/foreman/pull/4815 added
#21
Updated by The Foreman Bot almost 5 years ago
- Pull request https://github.com/theforeman/foreman/pull/4821 added
#22
Updated by Marek Hulán almost 5 years ago
- Legacy Backlogs Release (now unused) changed from 296 to 287
Refs #19707 - test searching domains with locs