Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort functionality not robust to missing order #2077

Closed
pgwillia opened this issue Jan 8, 2021 · 0 comments
Closed

Sort functionality not robust to missing order #2077

pgwillia opened this issue Jan 8, 2021 · 0 comments
Assignees
Labels

Comments

@pgwillia
Copy link
Member

pgwillia commented Jan 8, 2021

A plagarism checking bot has discovered a bug with our sorting. Can reproduce by visiting http://era.lvh.me:3000/search?sort=sort_year in development.

criteria[:sort_order] << if sort_attribute == :score
# When sorting by score it only makes sense to use :desc order from the user
# perspective so we ignore the order if one is given.
:desc
elsif order.present? && POSSIBLE_SORT_ORDERS.include?(order)
order
else
# We could not find the order so we switch to default sort direction
sort_direction_index = solr_exporter.default_sort_indexes.index(sort_attribute)
solr_exporter.default_sort_direction[sort_direction_index]
end

Where

  • sort_attribute is "sort_year_isi"
  • order is nil
  • solr_exporter.default_sort_indexes.index(sort_attribute) is nil

Then on line 81 the TypeError is thrown.

View details in Rollbar: https://rollbar.com/ualbertalib/jupiter/items/1192/


TypeError: no implicit conversion from nil to integer
  File "/var/www/sites/jupiter/app/models/jupiter_core/solr_services/deferred_faceted_solr_query.rb", line 80, in block in sort
  File "/var/www/sites/jupiter/app/models/jupiter_core/solr_services/deferred_faceted_solr_query.rb", line 49, in each
  File "/var/www/sites/jupiter/app/models/jupiter_core/solr_services/deferred_faceted_solr_query.rb", line 49, in each_with_index
  File "/var/www/sites/jupiter/app/models/jupiter_core/solr_services/deferred_faceted_solr_query.rb", line 49, in sort
  File "/var/www/sites/jupiter/app/services/user_search_service.rb", line 37, in results
  File "/var/www/sites/jupiter/app/controllers/search_controller.rb", line 24, in index
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/basic_implicit_render.rb", line 6, in send_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb", line 195, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/rendering.rb", line 30, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/callbacks.rb", line 42, in block in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb", line 135, in run_callbacks
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/callbacks.rb", line 41, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/rescue.rb", line 22, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/instrumentation.rb", line 33, in block in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb", line 180, in block in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb", line 180, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/instrumentation.rb", line 32, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/params_wrapper.rb", line 245, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/railties/controller_runtime.rb", line 27, in process_action
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb", line 136, in process
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionview-6.0.3.4/lib/action_view/rendering.rb", line 39, in process
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal.rb", line 190, in dispatch
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal.rb", line 254, in dispatch
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb", line 50, in dispatch
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb", line 33, in serve
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb", line 49, in block in serve
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb", line 32, in each
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb", line 32, in serve
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb", line 834, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/skylight-core-4.3.2/lib/skylight/core/probes/action_dispatch/routing/route_set.rb", line 14, in block in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/skylight-core-4.3.2/lib/skylight/core/fanout.rb", line 25, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/skylight-core-4.3.2/lib/skylight/core/probes/action_dispatch/routing/route_set.rb", line 13, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/omniauth-1.9.1/lib/omniauth/strategy.rb", line 420, in call_app!
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/omniauth-saml-1.10.3/lib/omniauth/strategies/saml.rb", line 86, in other_phase
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/omniauth-1.9.1/lib/omniauth/strategy.rb", line 190, in call!
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/omniauth-1.9.1/lib/omniauth/strategy.rb", line 169, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/omniauth-1.9.1/lib/omniauth/builder.rb", line 45, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/stack.rb", line 61, in block in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb", line 180, in block in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb", line 180, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/stack.rb", line 60, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb", line 15, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/stack.rb", line 61, in block in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb", line 180, in block in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb", line 180, in instrument
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/stack.rb", line 60, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/etag.rb", line 27, in call
  File "/var/www/sites/jupiter/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/stack.rb", l
@pgwillia pgwillia changed the title TypeError: no implicit conversion from nil to integer Some sort_year are not present Jan 8, 2021
@pgwillia pgwillia changed the title Some sort_year are not present Sort functionality not robust to missing order Jan 8, 2021
@pgwillia pgwillia removed the data label Jan 8, 2021
@ConnorSheremeta ConnorSheremeta self-assigned this Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants