Project

General

Profile

Actions

Bug #19707

closed

Searching for specific organizations/locations broken

Added by Anonymous almost 7 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Category:
Organizations and Locations
Target version:
Fixed in Releases:
Found in Releases:

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

proxies.png View proxies.png 17.5 KB Anonymous, 05/30/2017 12:40 PM

Related issues 2 (0 open2 closed)

Related to Foreman - Bug #20867: Scoped search 4.1.1 introduces a regression and breaks testsClosedMarek Hulán09/07/2017Actions
Related to Foreman - Bug #20872: Update scoped_search to 4.1.2 or higherClosedDaniel Lobato Garcia09/07/2017Actions
Actions #1

Updated by Anonymous almost 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'

Actions #2

Updated by Anonymous almost 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
Actions #3

Updated by Daniel Lobato Garcia almost 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.

Actions #4

Updated by Anonymous almost 7 years ago

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
}

Actions #5

Updated by Marek Hulán almost 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

Actions #6

Updated by Christian Schulze-Wiehenbrauk almost 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.

Actions #7

Updated by Christian Schulze-Wiehenbrauk almost 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.

Actions #8

Updated by Christian Schulze-Wiehenbrauk almost 7 years ago

Not sure how to contribute this besides a gist,
so here is the unit test:
https://gist.github.com/Ntr0/94c2bd1350253db0620933d297473b86

Actions #9

Updated by Jitendra Yejare over 6 years ago

  • Bugzilla link set to 1472863
Actions #10

Updated by Tomáš Strachota over 6 years ago

There's a similar issue with filtering hosts by hostgroups: http://projects.theforeman.org/issues/20204 Could be a dupe.

Actions #11

Updated by Tomáš Strachota over 6 years ago

Disregard my previous comment, it's a different bug.

Actions #12

Updated by Marek Hulán over 6 years ago

  • Target version set to 1.17.0-RC2
Actions #13

Updated by Marek Hulán over 6 years ago

  • Target version changed from 1.17.0-RC2 to 1.18.0-RC2
Actions #14

Updated by Ondřej Pražák over 6 years ago

  • Assignee set to Ondřej Pražák
Actions #15

Updated by Marek Hulán over 6 years ago

  • Target version changed from 1.18.0-RC2 to 214
Actions #16

Updated by Marek Hulán over 6 years ago

Fixed in scoped_search 4.1.1 but that introduced another regression so we ended up using 4.1.2.

Actions #17

Updated by Marek Hulán over 6 years ago

  • Related to Bug #20867: Scoped search 4.1.1 introduces a regression and breaks tests added
Actions #18

Updated by Marek Hulán over 6 years ago

  • Related to Bug #20872: Update scoped_search to 4.1.2 or higher added
Actions #19

Updated by Marek Hulán over 6 years ago

  • Status changed from New to Closed
  • translation missing: en.field_release set to 296

This has been addressed by #20872

Actions #20

Updated by Marek Hulán over 6 years ago

  • Pull request https://github.com/theforeman/foreman/pull/4815 added
Actions #21

Updated by The Foreman Bot over 6 years ago

  • Pull request https://github.com/theforeman/foreman/pull/4821 added
Actions #22

Updated by Marek Hulán over 6 years ago

  • translation missing: en.field_release changed from 296 to 287
Actions

Also available in: Atom PDF