ManageIQ / manageiq-ui-classic

Classic UI of ManageIQ
Apache License 2.0
50 stars 357 forks source link

Visiting /vm_or_template/explorer/:id yields an error #6696

Open Fryguy opened 4 years ago

Fryguy commented 4 years ago

While this is an uncommon route it is exposed via routes.rb and should seemingly redirect, but it gives this error...

[----] F, [2020-02-20T17:28:08.313450 #42457:3ff50a0512b8] FATAL -- : Error caught: [NoMethodError] undefined method `underscore' for nil:NilClass
/Users/jfrey/.gem/ruby/2.5.7/bundler/gems/manageiq-ui-classic-c5c45590cf53/app/controllers/vm_or_template_controller.rb:30:in `prefix_by_nodetype'
/Users/jfrey/.gem/ruby/2.5.7/bundler/gems/manageiq-ui-classic-c5c45590cf53/app/controllers/vm_or_template_controller.rb:38:in `set_elements_and_redirect_unauthorized_user'
/Users/jfrey/.gem/ruby/2.5.7/bundler/gems/manageiq-ui-classic-c5c45590cf53/app/controllers/mixins/vm_show_mixin.rb:41:in `explorer'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:186:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:131:in `run_callbacks'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:19:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/rescue.rb:20:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `block in instrument'
/Users/jfrey/.gem/ruby/2.5.7/gems/activesupport-5.1.7/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/jfrey/.gem/ruby/2.5.7/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `instrument'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/activerecord-5.1.7/lib/active_record/railties/controller_runtime.rb:22:in `process_action'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:124:in `process'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionview-5.1.7/lib/action_view/rendering.rb:30:in `process'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal.rb:189:in `dispatch'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal.rb:253:in `dispatch'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/routing/route_set.rb:31:in `serve'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/journey/router.rb:50:in `block in serve'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/journey/router.rb:33:in `each'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/journey/router.rb:33:in `serve'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/routing/route_set.rb:844:in `call'
/Users/jfrey/dev/manageiq/lib/request_started_on_middleware.rb:12:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/etag.rb:27:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/conditional_get.rb:27:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/head.rb:14:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/session/abstract/id.rb:269:in `context'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/session/abstract/id.rb:263:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/cookies.rb:613:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
/Users/jfrey/.gem/ruby/2.5.7/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:97:in `run_callbacks'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/callbacks.rb:24:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/executor.rb:12:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/railties-5.1.7/lib/rails/rack/logger.rb:36:in `call_app'
/Users/jfrey/.gem/ruby/2.5.7/gems/railties-5.1.7/lib/rails/rack/logger.rb:26:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/request_id.rb:25:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/method_override.rb:24:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/runtime.rb:24:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/activesupport-5.1.7/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/executor.rb:12:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/actionpack-5.1.7/lib/action_dispatch/middleware/static.rb:125:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/rack-2.1.2/lib/rack/sendfile.rb:113:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/secure_headers-3.9.0/lib/secure_headers/middleware.rb:12:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/railties-5.1.7/lib/rails/engine.rb:522:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/puma-4.3.1/lib/puma/configuration.rb:228:in `call'
/Users/jfrey/.gem/ruby/2.5.7/gems/puma-4.3.1/lib/puma/server.rb:681:in `handle_request'
/Users/jfrey/.gem/ruby/2.5.7/gems/puma-4.3.1/lib/puma/server.rb:472:in `process_client'
/Users/jfrey/.gem/ruby/2.5.7/gems/puma-4.3.1/lib/puma/server.rb:328:in `block in run'
/Users/jfrey/.gem/ruby/2.5.7/gems/puma-4.3.1/lib/puma/thread_pool.rb:134:in `block in spawn_thread'

cc @himdel

himdel commented 4 years ago

Right, so, the route actually does work, only it expects tree ids, not object ids.

So, first access to /vm_infra/explorer/v-1:

good

But access to /vm_infra/explorer/1:

bad

himdel commented 4 years ago

But, the second is not the "Record not found" screen, or anything nice, so this still needs fixing :).

Also, in the case of this explorer:

So, we should probably just accept a raw id as well.

miq-bot commented 4 years ago

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

Fryguy commented 4 years ago

cc @skateman Not sure if your dead routes detection was aware of this one or not. (it's not actually dead, so probably not...more just wanted it on your radar)

skateman commented 4 years ago

Yeah, working on it https://github.com/ManageIQ/manageiq-ui-classic/pull/7131

EDIT: this is not actually related to the dead routes, this can happen on any route. Basically anything you send after the / is treated as params[:id], this is a rails feature.

chessbyte commented 3 years ago

@Fryguy @kavyanekkalapu is this still an issue or resolved in #7131 ?

kavyanekkalapu commented 3 years ago

I am not able to understand the issue. Can we access specific record details of explorer table record using id?

Only route working for me is -> http://localhost:3000/vm_or_template/explorer#/

Fryguy commented 3 years ago

This is still an issue in the sense that the route table lets you hit a URL like http://localhost:3000/vm_or_template/explorer/1, but you get an error page with a stack trace issue that blows up as opposed to something like the 404 page, which is more expected. Similarly you can hit http://localhost:3000/vm_or_template/explorer/abc and instead of 404 it blows up. http://localhost:3000/vm_or_template/explorer/v-1 is an example of a URL that works correctly, because we expect a tree-id.

There are multiple ways to fix, the easiest being to just catch unexpected id values and redirect to 404. Alternatively, we could support id-based URLs as well which would allow for deep linking.

miq-bot commented 1 year ago

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.