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

URI::InvalidURIError: Raised When Querying Orgs With Non-ASCII Characters #733

Closed
aaronskiba opened this issue Apr 23, 2024 · 1 comment
Closed

Comments

@aaronskiba
Copy link
Collaborator

aaronskiba commented Apr 23, 2024

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)

  • 4.0.2+portage-4.0.3

Description

  • Some Organisations have non-ASCII characters (e.g. Many French organisations include é). However, when non-ASCII characters are queried in the http_get() method of app/services/external_apis/base_service.rb, the following is outputted in the terminal:
Class.BaseService.http_get URI must be ascii only "https://api.ror.org/organizations?query=C\u00E9g&page=1" received an invalid uri: 'https://api.ror.org/organizations?query=Cég&page=1'!

Class.ROR search received a  response with: nil!
# app/services/external_apis/base_service.rb
def http_get(uri:, additional_headers: {}, debug: false)
  return nil unless uri.present?

  HTTParty.get(uri, options(additional_headers: additional_headers,
                            debug: debug))
rescue URI::InvalidURIError => e
  handle_uri_failure(method: "BaseService.http_get #{e.message}",
                     uri: uri)
  nil
rescue HTTParty::Error => e
  handle_http_failure(method: "BaseService.http_get #{e.message}",
                      http_response: resp)
  resp
end

View details in Rollbar: https://app.rollbar.com/a/ualbertalib/fix/item/dmp_assistant/444


URI::InvalidURIError: URI must be ascii only "https://api.ror.org/organizations?query=C\u00E9gep&page=1"
  File "/usr/lib64/ruby/2.7.0/uri/rfc3986_parser.rb", line 21, in split
  File "/usr/lib64/ruby/2.7.0/uri/rfc3986_parser.rb", line 73, in parse
  File "/usr/lib64/ruby/2.7.0/uri/common.rb", line 234, in parse
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/httparty-0.21.0/lib/httparty/request.rb", line 85, in path=
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/httparty-0.21.0/lib/httparty/request.rb", line 75, in initialize
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/httparty-0.21.0/lib/httparty.rb", line 612, in new
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/httparty-0.21.0/lib/httparty.rb", line 612, in perform_request
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/httparty-0.21.0/lib/httparty.rb", line 526, in get
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/httparty-0.21.0/lib/httparty.rb", line 645, in get
  File "/var/www/sites/dmp/app/services/external_apis/base_service.rb", line 98, in http_get
  File "/var/www/sites/dmp/app/services/external_apis/ror_service.rb", line 89, in query_ror
  File "/var/www/sites/dmp/app/services/external_apis/ror_service.rb", line 68, in search
  File "/var/www/sites/dmp/app/services/org_selection/search_service.rb", line 81, in block in externals_search
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/cache.rb", line 752, in block in save_block_result_to_cache
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/cache.rb", line 726, in block in instrument
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb", line 205, in instrument
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/cache.rb", line 726, in instrument
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/cache.rb", line 751, in save_block_result_to_cache
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/cache.rb", line 343, in fetch
  File "/var/www/sites/dmp/app/services/org_selection/search_service.rb", line 80, in externals_search
  File "/var/www/sites/dmp/app/services/org_selection/search_service.rb", line 23, in search_combined
  File "/var/www/sites/dmp/app/controllers/orgs_controller.rb", line 177, in search
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal/basic_implicit_render.rb", line 6, in send_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/abstract_controller/base.rb", line 228, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal/rendering.rb", line 30, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/abstract_controller/callbacks.rb", line 42, in block in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb", line 117, in block in run_callbacks
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actiontext-6.1.7.6/lib/action_text/rendering.rb", line 20, in with_renderer
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actiontext-6.1.7.6/lib/action_text/engine.rb", line 59, in block (4 levels) in <class:Engine>
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb", line 126, in instance_exec
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb", line 126, in block in run_callbacks
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb", line 137, in run_callbacks
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/abstract_controller/callbacks.rb", line 41, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal/rescue.rb", line 22, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal/instrumentation.rb", line 34, in block in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb", line 203, in block in instrument
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb", line 203, in instrument
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal/instrumentation.rb", line 33, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal/params_wrapper.rb", line 249, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/activerecord-6.1.7.6/lib/active_record/railties/controller_runtime.rb", line 27, in process_action
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/abstract_controller/base.rb", line 165, in process
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionview-6.1.7.6/lib/action_view/rendering.rb", line 39, in process
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal.rb", line 190, in dispatch
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_controller/metal.rb", line 254, in dispatch
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_dispatch/routing/route_set.rb", line 50, in dispatch
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_dispatch/routing/route_set.rb", line 33, in serve
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_dispatch/journey/router.rb", line 50, in block in serve
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_dispatch/journey/router.rb", line 32, in each
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_dispatch/journey/router.rb", line 32, in serve
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/actionpack-6.1.7.6/lib/action_dispatch/routing/route_set.rb", line 842, in call
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/omniauth-2.1.2/lib/omniauth/strategy.rb", line 202, in call!
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/omniauth-2.1.2/lib/omniauth/strategy.rb", line 169, in call
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/omniauth-2.1.2/lib/omniauth/strategy.rb", line 202, in call!
  File "/var/www/sites/dmp/vendor/ruby/2.7.0/gems/omniauth-2.1.2/lib/omniauth/strategy.rb", line 169, in call
  File "/va
@aaronskiba aaronskiba changed the title NoMethodError: undefined method `call' for nil:NilClass URI::InvalidURIError: Raised When Querying Orgs With Non-ASCII Characters Apr 30, 2024
@aaronskiba
Copy link
Collaborator Author

PR #738 deactivates external API requests to https://api.ror.org. If merged, then this error may no longer be raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant