Bug 2002202

Summary: Search box in the Partition Tables page throws an Rails error
Product: Red Hat Satellite Reporter: Ondrej Gajdusek <ogajduse>
Component: SearchAssignee: Adam Ruzicka <aruzicka>
Status: VERIFIED --- QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.10.0CC: afeferku, apatel, aruzicka, kgaikwad, lhellebr, mhulan, pcreech, rlavi
Target Milestone: 6.14.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-scoped_search-4.1.11 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
foreman-rake errors:fetch_log none

Description Ondrej Gajdusek 2021-09-08 08:51:32 UTC
Created attachment 1821429 [details]
foreman-rake errors:fetch_log

Description of problem:
Search on the Partition Tables throws an error in some cases.

Version-Release number of selected component (if applicable):
Satellite 6.10

How reproducible:
always

Steps to Reproduce:
1. Navigate to Hosts -> Partition Tables
2. Enter "Atomic Kickstart default" into the search bar and submit it.

Actual results:
The following error is shown to the user:
Oops, we're sorry but something went wrong wrong number of bind variables (8 for 9) in: (("templates"."name" ILIKE ? OR "templates"."template" ILIKE ? OR "templates"."template" ILIKE ? OR "templates"."os_family" ILIKE ?) AND ("templates"."name" ILIKE ? OR "templates"."template" ILIKE ? OR "templates"."template" ILIKE ? OR "templates"."os_family" ILIKE ?) AND (["(\"templates\".\"default\" <> ?)", false]))

Expected results:
No error should be thrown and no results should be shown as "Atomic Kickstart default" is a name of the Provisioning Template (assuming default Satellite instance)

Additional info:
Tested on both 6.10 and 6.9. This is not a regression.
Attached logs come from 6.9.

Comment 1 Marek Hulan 2021-09-09 08:18:46 UTC
A quick workaround - wrap the whole string in quotes, "Atomic Kickstart default". Or don't use the wide searching through all attributes, in this case it seems the customer wants to search by partition table name, so use the search term 

> name ~ "Atomic Kickstart default"

The issue is likely in the word default, which seems to have some special meaning in the scoped search syntax.

Comment 2 Adam Ruzicka 2022-05-31 12:37:02 UTC
> which seems to have some special meaning in the scoped search syntax

It has no special meaning in scoped search itself, it is caused by us defining "default" as a searchable field of type set. This will need to be fixed in scoped_search itself.

In the mean time, if you want to search for multiple words, use quotes.

Comment 5 Lukáš Hellebrandt 2023-07-17 15:47:54 UTC
Verified with Sat 6.14.0 snap 7.0.

Searching for "Atomic Kickstart default" without quotes in Provisioning templates finds a template.
Searching for "Atomic Kickstart default" without quotes in Partition tables doesn't find anything.
Searching for "Preseed default" without quotes in Partition tables finds the Preseed default table.
Searching for 'name = "Preseed default"' without single quotes in Partition tables finds the Preseed default table.
Searching for "default = true" without quotes in Partition tables finds all tables marked as default.

# hammer partition-table list --search='name = "Preseed default"'
----|-----------------|----------
ID  | NAME            | OS FAMILY
----|-----------------|----------
146 | Preseed default | Debian   
----|-----------------|----------
# hammer partition-table list --search='"Preseed default"'
----|-----------------------------|----------
ID  | NAME                        | OS FAMILY
----|-----------------------------|----------
146 | Preseed default             | Debian   
147 | Preseed default autoinstall | Debian   
148 | Preseed default LVM         | Debian   
----|-----------------------------|----------
# hammer partition-table list --search='Preseed default'
----|-----------------------------|----------
ID  | NAME                        | OS FAMILY
----|-----------------------------|----------
146 | Preseed default             | Debian   
147 | Preseed default autoinstall | Debian   
148 | Preseed default LVM         | Debian   
----|-----------------------------|----------