alexbevi / redmine_knowledgebase

A knowledgebase plugin for Redmine
452 stars 199 forks source link

500 Internal Server Error - undefined method `title' for nil:NilClass #292

Closed korn87 closed 8 years ago

korn87 commented 9 years ago

Hey Recently I was about to use Knowledge base plugin, installed and everything, but when we started to insert articles at some moment, page threw 500 internal server error. It seems that it was caused by removin category, but person responsible for the issue is unable to exacly explain what he did (so possibly removing category might not be the case).

I will be much obliged for any help with this.

Environment variables:

Environment:
  Redmine version                2.6.4.stable
  Ruby version                   2.0.0-p645 (2015-04-13) [x86_64-linux]
  Rails version                  3.2.21
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.13
  Git                            1.9.5
  Filesystem                     
Redmine plugins:
  projects_tree_view             0.0.8
  redmine_default_assign         0.2.0
  redmine_exception_handler      2.0.0.devel.56f6d28645
  redmine_fields_permissions     1.0.0
  redmine_importer               0.4.1
  redmine_knowledgebase          3.0.7
  redmine_local_avatars          0.2.0
  redmine_mentions               0.0.1
  redmine_my_page_queries        2.1.6
  redmine_planning               0.7.6
  redmine_thumbnails             0.1.0

Stack trace:

An ActionView::Template::Error occurred in articles#index:

  undefined method `title' for nil:NilClass
  plugins/redmine_knowledgebase/app/helpers/knowledgebase_helper.rb:16:in `format_article_summary'

-------------------------------
Request:
-------------------------------

  * URL        : http://192.168.189.204/projects/knowledge-database/knowledgebase/articles
  * HTTP Method: GET
  * IP address : 192.168.189.165
  * Parameters : {"action"=>"index", "controller"=>"articles", "project_id"=>"knowledge-database"}
  * Timestamp  : 2015-09-10 10:17:44 UTC
  * Server : linux
  * Rails root : /opt/bitnami/apps/redmine/htdocs
  * Process: 1985

-------------------------------
Session:
-------------------------------

  * session id: "2c3e40bda781b2b6745b7732205717ef"
  * data: {"user_id"=>5,
   "ctime"=>1441880205,
   "atime"=>1441880263,
   "session_id"=>"2c3e40bda781b2b6745b7732205717ef",
   "_csrf_token"=>"7UM1SBLS+TtglpiRzjcdHUk0OuE84F4U7bUhhdrKaKU=",
   "flash"=>
    #>}

-------------------------------
Environment:
-------------------------------

  * HTTP_ACCEPT                                    : text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  * HTTP_ACCEPT_ENCODING                           : gzip, deflate
  * HTTP_ACCEPT_LANGUAGE                           : pl,en-US;q=0.7,en;q=0.3
  * HTTP_COOKIE                                    : _redmine_session=BAh7C0kiDHVzZXJfaWQGOgZFRmkKSSIKY3RpbWUGOwBGbCsHjVjxVUkiCmF0aW1lBjsARmwrB8RY8VVJIg9zZXNzaW9uX2lkBjsAVEkiJTJjM2U0MGJkYTc4MWIyYjY3NDViNzczMjIwNTcxN2VmBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMTdVTTFTQkxTK1R0Z2xwaVJ6amNkSFVrME91RTg0RjRVN2JVaGhkckthS1U9BjsARkkiCmZsYXNoBjsAVG86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGOgtub3RpY2VUOgxAY2xvc2VkRjoNQGZsYXNoZXN7BjsKSSIXU3VjY2Vzc2Z1bCB1cGRhdGUuBjsAVDoJQG5vdzA%3D--f7659590eb8a67a3ff61fcfed0bac34312c8eb0b
  * HTTP_HOST                                      : 192.168.189.204
  * HTTP_REFERER                                   : http://192.168.189.204/projects/knowledge-database/settings/modules
  * HTTP_USER_AGENT                                : Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
  * ORIGINAL_FULLPATH                              : /projects/knowledge-database/knowledgebase/articles
  * PASSENGER_CONNECT_PASSWORD                     : [FILTERED]
  * PATH_INFO                                      : /projects/knowledge-database/knowledgebase/articles
  * QUERY_STRING                                   : 
  * REMOTE_ADDR                                    : 192.168.189.165
  * REMOTE_PORT                                    : 50999
  * REQUEST_METHOD                                 : GET
  * REQUEST_URI                                    : /projects/knowledge-database/knowledgebase/articles
  * SCRIPT_NAME                                    : 
  * SERVER_NAME                                    : 192.168.189.204
  * SERVER_PORT                                    : 80
  * SERVER_PROTOCOL                                : HTTP/1.1
  * SERVER_SOFTWARE                                : Apache/2.4.12 (Unix) OpenSSL/1.0.1m SVN/1.8.13 Phusion_Passenger/5.0.6
  * action_controller.instance                     : #
  * action_dispatch.backtrace_cleaner              : #
  * action_dispatch.cookies                        : #
  * action_dispatch.logger                         : #
  * action_dispatch.parameter_filter               : [:password, /RAW_POST_DATA/]
  * action_dispatch.remote_ip                      : 192.168.189.165
  * action_dispatch.request.content_type           : 
  * action_dispatch.request.formats                : [#]
  * action_dispatch.request.parameters             : {"action"=>"index", "controller"=>"articles", "project_id"=>"knowledge-database"}
  * action_dispatch.request.path_parameters        : {:action=>"index", :controller=>"articles", :project_id=>"knowledge-database"}
  * action_dispatch.request.query_parameters       : {}
  * action_dispatch.request.request_parameters     : {}
  * action_dispatch.request.unsigned_session_cookie: {"user_id"=>5, "ctime"=>1441880205, "atime"=>1441880260, "session_id"=>"2c3e40bda781b2b6745b7732205717ef", "_csrf_token"=>"7UM1SBLS+TtglpiRzjcdHUk0OuE84F4U7bUhhdrKaKU=", "flash"=>#, @closed=false, @flashes={}, @now=nil>}
  * action_dispatch.request_id                     : 36815b795324464c7371ae9376355031
  * action_dispatch.routes                         : #
  * action_dispatch.secret_token                   : 87fd77226182e74096c55f5e27265ef2f41fcd4e1f7ef1f7543aee350f4f3a178b0b34f4214a2471
  * action_dispatch.show_detailed_exceptions       : false
  * action_dispatch.show_exceptions                : true
  * rack-cache.allow_reload                        : false
  * rack-cache.allow_revalidate                    : false
  * rack-cache.cache_key                           : Rack::Cache::Key
  * rack-cache.default_ttl                         : 0
  * rack-cache.entitystore                         : rails:/
  * rack-cache.ignore_headers                      : ["Set-Cookie"]
  * rack-cache.metastore                           : rails:/
  * rack-cache.private_headers                     : ["Authorization", "Cookie"]
  * rack-cache.storage                             : #
  * rack-cache.use_native_ttl                      : false
  * rack-cache.verbose                             : false
  * rack.errors                                    : #
  * rack.hijack                                    : #
  * rack.hijack?                                   : true
  * rack.input                                     : #
  * rack.multiprocess                              : true
  * rack.multithread                               : false
  * rack.request.cookie_hash                       : {"_redmine_session"=>"BAh7C0kiDHVzZXJfaWQGOgZFRmkKSSIKY3RpbWUGOwBGbCsHjVjxVUkiCmF0aW1lBjsARmwrB8RY8VVJIg9zZXNzaW9uX2lkBjsAVEkiJTJjM2U0MGJkYTc4MWIyYjY3NDViNzczMjIwNTcxN2VmBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMTdVTTFTQkxTK1R0Z2xwaVJ6amNkSFVrME91RTg0RjRVN2JVaGhkckthS1U9BjsARkkiCmZsYXNoBjsAVG86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGOgtub3RpY2VUOgxAY2xvc2VkRjoNQGZsYXNoZXN7BjsKSSIXU3VjY2Vzc2Z1bCB1cGRhdGUuBjsAVDoJQG5vdzA=--f7659590eb8a67a3ff61fcfed0bac34312c8eb0b"}
  * rack.request.cookie_string                     : _redmine_session=BAh7C0kiDHVzZXJfaWQGOgZFRmkKSSIKY3RpbWUGOwBGbCsHjVjxVUkiCmF0aW1lBjsARmwrB8RY8VVJIg9zZXNzaW9uX2lkBjsAVEkiJTJjM2U0MGJkYTc4MWIyYjY3NDViNzczMjIwNTcxN2VmBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMTdVTTFTQkxTK1R0Z2xwaVJ6amNkSFVrME91RTg0RjRVN2JVaGhkckthS1U9BjsARkkiCmZsYXNoBjsAVG86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGOgtub3RpY2VUOgxAY2xvc2VkRjoNQGZsYXNoZXN7BjsKSSIXU3VjY2Vzc2Z1bCB1cGRhdGUuBjsAVDoJQG5vdzA%3D--f7659590eb8a67a3ff61fcfed0bac34312c8eb0b
  * rack.request.query_hash                        : {}
  * rack.request.query_string                      : 
  * rack.run_once                                  : false
  * rack.session                                   : {"user_id"=>5, "ctime"=>1441880205, "atime"=>1441880263, "session_id"=>"2c3e40bda781b2b6745b7732205717ef", "_csrf_token"=>"7UM1SBLS+TtglpiRzjcdHUk0OuE84F4U7bUhhdrKaKU=", "flash"=>#, @closed=false, @flashes={}, @now=nil>}
  * rack.session.options                           : {:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :secret=>"4ba1fa05e74f2eed94acf382c4e93b0b828b5f3893f8e815d676085e0a2a", :coder=>#, :id=>"2c3e40bda781b2b6745b7732205717ef"}
  * rack.url_scheme                                : http
  * rack.version                                   : [1, 2]

-------------------------------
Backtrace:
-------------------------------

  plugins/redmine_knowledgebase/app/helpers/knowledgebase_helper.rb:16:in `format_article_summary'
  plugins/redmine_knowledgebase/app/views/articles/_list.html.erb:5:in `block in _plugins_redmine_knowledgebase_app_views_articles__list_html_erb___3857921995263350474_70267794441440'
  plugins/redmine_knowledgebase/app/views/articles/_list.html.erb:1:in `each'
  plugins/redmine_knowledgebase/app/views/articles/_list.html.erb:1:in `_plugins_redmine_knowledgebase_app_views_articles__list_html_erb___3857921995263350474_70267794441440'
  actionpack (3.2.21) lib/action_view/template.rb:145:in `block in render'
  activesupport (3.2.21) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.21) lib/action_view/template.rb:143:in `render'
  actionpack (3.2.21) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
  actionpack (3.2.21) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
  actionpack (3.2.21) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.21) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.21) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.21) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.21) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.21) lib/action_view/renderer/partial_renderer.rb:237:in `render'
  actionpack (3.2.21) lib/action_view/renderer/renderer.rb:41:in `render_partial'
  actionpack (3.2.21) lib/action_view/renderer/renderer.rb:15:in `render'
  actionpack (3.2.21) lib/action_view/helpers/rendering_helper.rb:24:in `render'
  plugins/redmine_knowledgebase/app/views/articles/index.html.erb:36:in `_plugins_redmine_knowledgebase_app_views_articles_index_html_erb___535091624849864628_70267793159460'
  actionpack (3.2.21) lib/action_view/template.rb:145:in `block in render'
  activesupport (3.2.21) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.21) lib/action_view/template.rb:143:in `render'
  actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
  actionpack (3.2.21) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.21) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.21) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.21) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.21) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
  actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
  actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
  actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:18:in `render'
  actionpack (3.2.21) lib/action_view/renderer/renderer.rb:36:in `render_template'
  actionpack (3.2.21) lib/action_view/renderer/renderer.rb:17:in `render'
  actionpack (3.2.21) lib/abstract_controller/rendering.rb:110:in `_render_template'
  actionpack (3.2.21) lib/action_controller/metal/streaming.rb:225:in `_render_template'
  actionpack (3.2.21) lib/abstract_controller/rendering.rb:103:in `render_to_body'
  actionpack (3.2.21) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
  actionpack (3.2.21) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
  actionpack (3.2.21) lib/abstract_controller/rendering.rb:88:in `render'
  actionpack (3.2.21) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
  activesupport (3.2.21) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
  /opt/bitnami/ruby/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
  activesupport (3.2.21) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
  actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
  activerecord (3.2.21) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
  actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:39:in `render'
  actionpack (3.2.21) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  actionpack (3.2.21) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
  actionpack (3.2.21) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.21) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.21) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.21) lib/active_support/callbacks.rb:502:in `_run__894343866148720765__process_action__3673630013489387623__callbacks'
  activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.21) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.21) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.21) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.21) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.21) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.21) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.21) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.21) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.21) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.21) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.21) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.21) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.21) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.21) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:608:in `call'
  exception_notification (4.1.1) lib/exception_notification/rack.rb:32:in `call'
  rack-openid (1.4.2) lib/rack/openid.rb:98:in `call'
  request_store (1.0.5) lib/request_store/middleware.rb:9:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.21) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.21) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `_run__3655450406270983396__call__1543822919614028138__callbacks'
  activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.21) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.21) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.21) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.21) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.21) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.21) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.21) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.21) lib/action_dispatch/middleware/static.rb:83:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.21) lib/rails/engine.rb:484:in `call'
  railties (3.2.21) lib/rails/application.rb:231:in `call'
  railties (3.2.21) lib/rails/railtie/configurable.rb:30:in `method_missing'
  rack (1.4.5) lib/rack/builder.rb:134:in `call'
  rack (1.4.5) lib/rack/urlmap.rb:64:in `block in call'
  rack (1.4.5) lib/rack/urlmap.rb:49:in `each'
  rack (1.4.5) lib/rack/urlmap.rb:49:in `call'
  passenger (5.0.6) lib/phusion_passenger/rack/thread_handler_extension.rb:85:in `process_request'
  passenger (5.0.6) lib/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
  passenger (5.0.6) lib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
  passenger (5.0.6) lib/phusion_passenger/request_handler.rb:414:in `block (3 levels) in start_threads'
  passenger (5.0.6) lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
korn87 commented 8 years ago

We have handled it by commenting below 4 lines in: https://github.com/alexbevi/redmine_knowledgebase/blob/master/app/helpers/knowledgebase_helper.rb, ...and recreating previously deleted categories.

when "updated"

(:label_summary_updated_articles,

:ago => time_ago_in_words(article.updated_at),

:category => link_to(article.category.title, {:controller => 'categories', :action => 'show', :id => article.category_id}))

But still, I would not close the subject, as issue should not appear in the first place. There sould be some confirmation prompt before deleting not empty category. If so issue will not appear.

alexbevi commented 8 years ago

@korn87 this was resolved in v3.2.0 by not allowing categories with subcategories to be purged