Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1365013 - CloudForms REST API searching for reports by names that contain '>' fails with a '400 - Bad Request'
Summary: CloudForms REST API searching for reports by names that contain '>' fails wit...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.7.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.9.0
Assignee: Tim Wade
QA Contact: Martin Kourim
URL:
Whiteboard: rest:report
Depends On:
Blocks: 1481296
TreeView+ depends on / blocked
 
Reported: 2016-08-08 11:12 UTC by Nikhil Gupta
Modified: 2018-03-06 15:40 UTC (History)
10 users (show)

Fixed In Version: 5.9.0.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1481296 (view as bug list)
Environment:
Last Closed: 2018-03-06 15:40:57 UTC
Category: ---
Cloudforms Team: ---


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2488041 None None None 2016-08-08 12:16:14 UTC

Description Nikhil Gupta 2016-08-08 11:12:33 UTC
Description of problem:
Searching for a report with a name that contains a '>' like 'VMs with Free Space > 50% by Department' fails with a '400 - Bad Request'

REST API Request:
----------------------
http://my_cf_appliance/api/reports?filter[]=name='VMs%20with%20Free%20Space%20%3E%2050%25%20by%20Department'&limit=1&expand=resources

from production.log:
-----------------------
[----] I, [2016-08-02T16:33:19.605148 #29533:9b7e90]  INFO -- : Started GET "/api/reports?filter[]=name='VMs%20with%20Free%20Space%20%3E%2050%25%20by%20Department'&limit=1&expand=resources" for 127.0.0.1 at 2016-08-02 16:33:19 -0400
[----] I, [2016-08-02T16:33:19.634327 #29533:9b7e90]  INFO -- : Processing by ApiController#show as JSON
[----] I, [2016-08-02T16:33:19.634415 #29533:9b7e90]  INFO -- :   Parameters: {"filter"=>["name='VMs with Free Space > 50% by Department'"], "limit"=>"1", "expand"=>"resources", "suffix"=>"reports"}
[----] I, [2016-08-02T16:33:20.668993 #29533:9b7e90]  INFO -- : CONNECTION RETRY: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter retry #0.
[----] I, [2016-08-02T16:33:20.694171 #29533:9b7e90]  INFO -- : Completed 400 Bad Request in 1059.6ms (Views: 0.5ms | ActiveRecord: 1045.8ms)

from evm.log:
-----------------
[----] E, [2016-08-02T16:44:48.233809 #29533:9b7e90] ERROR -- : MIQ(abstract_adapter) Name: [], Message: [PGError: ERROR:  column miq_reports.name='VMs with Free Space does not exist
LINE 1: ...0000 AND "miq_reports".id <= 10999999999999) AND ("miq_repor...
                                                             ^
...: SELECT COUNT(*) FROM "miq_reports"  WHERE ("miq_reports".id >= 10000000000000 AND "miq_reports".id <= 10999999999999) AND ("miq_reports"."name='VMs with Free Space" > '50% by Department''')...]

Version-Release number of selected component (if applicable):
cfme-5.4.4.2-1.el6cf.x86_64

How reproducible:
Always

Steps to Reproduce:
HTTP GET request for a report:
https://my_cf_appliance/api/reports?filter[]=name=VMs with Free Space > 50% by Department

Actual results:
400 - Bad Request

Expected results:
HTTP api get request should process the special characters and give report details.

Comment 2 Sachin 2017-04-04 09:14:20 UTC
Do we have any update of this bug?

Comment 4 Sachin 2017-06-07 04:18:41 UTC
I do not see this bug on following versions on CloudForms:

5.6.1.2.20160810181333_8ba817b 
5.7.2.1.20170406142927_0a1ad0e 
5.8.0.17.20170525183055_6317a22 

Please close this bug

Comment 5 Sachin 2017-06-07 04:22:00 UTC
Sorry..those were CFME versions

Comment 7 Tim Wade 2017-07-10 19:42:20 UTC
I've created a PR here that addresses the issue in the description here: https://github.com/ManageIQ/manageiq/pull/15534

However, you have a distinct separate issue in the example you provided. '%' acts as a wildcard, so may give you unexpected results (though I'd expect your query to still work). We should probably create a new issue for this. Currently there's no way for us to tell if you meant a literal percent sign of wildcard (we assume wildcard in all cases).

Comment 10 Martin Kourim 2017-10-17 19:57:28 UTC
Verified with GET /api/reports?filter[]=name='VMs%20with%20Free%20Space%20%3E%2050%25%20by%20Department'&limit=1&expand=resources


Note You need to log in before you can comment on or make changes to this bug.