Bug 1242534 - API List content_view_filters rules error
Summary: API List content_view_filters rules error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Content Views
Version: 6.1.8
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: Unspecified
Assignee: Tom McKay
QA Contact: jcallaha
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1122832 1391042
TreeView+ depends on / blocked
 
Reported: 2015-07-13 14:03 UTC by Peter Vreman
Modified: 2019-12-16 04:49 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1391042 (view as bug list)
Environment:
Last Closed: 2016-11-02 13:09:16 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 11920 0 None None None 2016-04-26 16:55:09 UTC

Description Peter Vreman 2015-07-13 14:03:25 UTC
Description of problem:

# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"organization_id\":3}" -XGET https://localhost/katello/api/v2/content_view_filters/17/rules
{"displayMessage":"Unable to order by column 'name_sort'.","errors":["Unable to order by column 'name_sort'."]}

Traces from Logs:

2015-07-13 13:46:17 [I] Processing by Katello::Api::V2::ContentViewFilterRulesController#index as */*
2015-07-13 13:46:17 [I]   Parameters: {"per_page"=>9999, "api_version"=>"v2", "content_view_filter_id"=>"18", "content_view_filter_rule"=>{"per_page"=>9999}}
2015-07-13 13:46:17 [I] Authorized user hoici(hoici )
2015-07-13 13:46:17 [E] RuntimeError: Unable to order by column 'name_sort'.
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/models/katello/glue/elastic_search/items.rb:129:in `handle_search_request_fail'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/models/katello/glue/elastic_search/items.rb:124:in `rescue in retrieve'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/models/katello/glue/elastic_search/items.rb:52:in `retrieve'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/controllers/katello/api/v2/api_controller.rb:77:in `item_search'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb:26:in `index'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:528:in `block (4 levels) in _run__2536660760801069728__process_action__10151642543491308
72__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_11549'
/usr/share/foreman/app/controllers/api/v2/base_controller.rb:151:in `disable_json_root'
...
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
/opt/rh/ruby193/root/usr/share/gems/gems/logging-1.8.1/lib/logging/diagnostic_context.rb:323:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/logging-1.8.1/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
caused by: (Tire::Search::SearchRequestFailed) 400 : {"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[sZsR1HcsSOu_0MFgsdIo5A][katello_katello::contentviewerratumfilterrule][0]: SearchParseException[[katello_katello::contentviewerratumfilterrule][0]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"match_all\":{}},\"sort\":[{\"name_sort\":\"asc\"}],\"filter\":{\"and\":[{\"terms\":{\"id\":[]}}]},\"size\":9999,\"from\":0,\"fields\":[\"id\"]}]]]; nested: SearchParseException[[katello_katello::contentviewerratumfilterrule][0]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No mapping found for [name_sort] in order to sort on]]; }{[sZsR1HcsSOu_0MFgsdIo5A][katello_katello::contentviewerratumfilterrule][1]: SearchParseException[[katello_katello::contentviewerratumfilterrule][1]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"match_all\":{}},\"sort\":[{\"name_sort\":\"asc\"}],\"filter\":{\"and\":[{\"terms\":{\"id\":[]}}]},\"size\":9999,\"from\":0,\"fields\":[\"id\"]}]]]; nested: SearchParseException[[katello_katello::contentviewerratumfilterrule][1]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No mapping found for [name_sort] in order to sort on]]; }{[sZsR1HcsSOu_0MFgsdIo5A][katello_katello::contentviewerratumfilterrule][2]: SearchParseException[[katello_katello::contentviewerratumfilterrule][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"match_all\":{}},\"sort\":[{\"name_sort\":\"asc\"}],\"filter\":{\"and\":[{\"terms\":{\"id\":[]}}]},\"size\":9999,\"from\":0,\"fields\":[\"id\"]}]]]; nested: SearchParseException[[katello_katello::contentviewerratumfilterrule][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No mapping found for [name_sort] in order to sort on]]; }]","status":400}
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/search.rb:145:in `perform'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/search.rb:35:in `results'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/model/search.rb:105:in `search'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/model/search.rb:300:in `search'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/models/katello/glue/elastic_search/items.rb:85:in `retrieve'
    ... skipped 113 lines
2015-07-13 13:46:17 [I] Completed 500 Internal Server Error in 110ms (Views: 0.5ms | ActiveRecord: 7.5ms)


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


How reproducible:


Steps to Reproduce:
1. Create filter
2. List filter rule
3.

Actual results:
Error

Expected results:
Listing of rules


Additional info:

Comment 1 RHEL Program Management 2015-07-13 14:04:16 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Peter Vreman 2015-07-14 10:37:52 UTC
Issue is that Filter rules do not have a name field to sort on

Quick patch is below to use the id instead

/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/controllers/katello/api/v2# diff -u content_view_filter_rules_controller.rb.150714-1 content_view_filter_rules_controller.rb
--- content_view_filter_rules_controller.rb.150714-1    2015-07-14 09:37:34.626750747 +0000
+++ content_view_filter_rules_controller.rb     2015-07-14 09:38:25.849705473 +0000
@@ -99,6 +99,10 @@

     private

+    def sort_params
+      {sort_by: 'id'}
+    end
+
     def find_filter
       @filter = ContentViewFilter.find(params[:content_view_filter_id])
     end

Better would be to have a rule_order field that also allows to specify the order of the rules to be applied

Comment 5 jaudet 2015-09-01 17:14:32 UTC
Listing a content view's filters succeeds when the content view is of type "rpm" or "package_group". It fails when the content view is of type "erratum". I've written a new automated test that verifies this fact, and the traceback in the first comment also mentions errata.

Comment 6 jaudet 2015-09-01 17:17:05 UTC
Sorry. That should say "succeeds when the content view **filter** is of type 'rpm' or...".

Comment 7 jaudet 2015-09-01 17:20:31 UTC
See the automated test at: https://github.com/SatelliteQE/robottelo/pull/2724

Comment 10 Tom McKay 2015-09-22 14:26:37 UTC
Created redmine issue http://projects.theforeman.org/issues/11920 from this bug

Comment 11 Bryan Kearney 2015-09-22 16:00:37 UTC
Upstream bug component is WebUI

Comment 13 Bryan Kearney 2016-01-04 21:29:03 UTC
Upstream bug assigned to tomckay@redhat.com

Comment 14 Bryan Kearney 2016-02-02 11:01:09 UTC
Upstream bug assigned to tomckay@redhat.com

Comment 15 Bryan Kearney 2016-04-19 13:42:04 UTC
Per upstream, this was related to elastic search which has been removed. I am moving this to ON_QA for verification.

Comment 16 jcallaha 2016-07-07 18:26:36 UTC
Verified in Satellite 6.2 Beta Snap 19.

GET https://rhsm-qe-1.rhq.lab.eng.bos.redhat.com/katello/api/v2/content_view_filters/6/rules/


{
  "total": 5,
  "subtotal": 5,
  "page": null,
  "per_page": null,
  "error": null,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "content_view_filter_id": 6,
      "errata_id": "RHBA-2016:1349",
      "date_type": "updated",
      "id": 1,
      "created_at": "2016-06-30 19:47:56 UTC",
      "updated_at": "2016-06-30 19:47:56 UTC"
    },
    {
      "content_view_filter_id": 6,
      "errata_id": "RHBA-2016:1253",
      "date_type": "updated",
      "id": 2,
      "created_at": "2016-06-30 19:47:56 UTC",
      "updated_at": "2016-06-30 19:47:56 UTC"
    },
    {
      "content_view_filter_id": 6,
      "errata_id": "RHBA-2016:1251",
      "date_type": "updated",
      "id": 3,
      "created_at": "2016-06-30 19:47:56 UTC",
      "updated_at": "2016-06-30 19:47:56 UTC"
    },
    {
      "content_view_filter_id": 6,
      "errata_id": "RHBA-2016:1305",
      "date_type": "updated",
      "id": 4,
      "created_at": "2016-06-30 19:47:56 UTC",
      "updated_at": "2016-06-30 19:47:56 UTC"
    },
    {
      "content_view_filter_id": 6,
      "errata_id": "RHBA-2016:1259",
      "date_type": "updated",
      "id": 5,
      "created_at": "2016-06-30 19:47:56 UTC",
      "updated_at": "2016-06-30 19:47:56 UTC"
    }
  ]
}

Comment 17 Bryan Kearney 2016-07-27 11:21:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501


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