Bug #19707
closedSearching 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
Files
Updated by Anonymous over 7 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'
Updated by Anonymous over 7 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
Updated by Daniel Lobato Garcia over 7 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.
Updated by Anonymous over 7 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 }
Updated by Marek Hulán over 7 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
Updated by Christian Schulze-Wiehenbrauk over 7 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.
Updated by Christian Schulze-Wiehenbrauk over 7 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.
Updated by Christian Schulze-Wiehenbrauk over 7 years ago
Not sure how to contribute this besides a gist,
so here is the unit test:
https://gist.github.com/Ntr0/94c2bd1350253db0620933d297473b86
Updated by Tomáš Strachota about 7 years ago
There's a similar issue with filtering hosts by hostgroups: http://projects.theforeman.org/issues/20204 Could be a dupe.
Updated by Tomáš Strachota about 7 years ago
Disregard my previous comment, it's a different bug.
Updated by Marek Hulán about 7 years ago
- Target version changed from 1.17.0-RC2 to 1.18.0-RC2
Updated by Marek Hulán about 7 years ago
- Target version changed from 1.18.0-RC2 to 214
Updated by Marek Hulán about 7 years ago
Fixed in scoped_search 4.1.1 but that introduced another regression so we ended up using 4.1.2.
Updated by Marek Hulán about 7 years ago
- Related to Bug #20867: Scoped search 4.1.1 introduces a regression and breaks tests added
Updated by Marek Hulán about 7 years ago
- Related to Bug #20872: Update scoped_search to 4.1.2 or higher added
Updated by Marek Hulán about 7 years ago
- Status changed from New to Closed
- Translation missing: en.field_release set to 296
This has been addressed by #20872
Updated by Marek Hulán about 7 years ago
- Pull request https://github.com/theforeman/foreman/pull/4815 added
Updated by The Foreman Bot about 7 years ago
- Pull request https://github.com/theforeman/foreman/pull/4821 added
Updated by Marek Hulán about 7 years ago
- Translation missing: en.field_release changed from 296 to 287