TravisSpangle / redmine_spent_time_in_issue_description

Redmine Plugin that drops Time Entry data into the Issue Description
16 stars 16 forks source link

Error 500 when displaying an issue #12

Closed frconil closed 9 years ago

frconil commented 9 years ago

HI,

I have to admit this one is puzzling me a bit.

We have two instances of redmine using the same code and relatively similar data in postgresql.

On one instance, we get 500 errors whenever trying to access a page that include the plugin, or even the plugin settings itself!

For instance the settings page:

Started GET "/settings/plugin/redmine_spent_time_in_issue_description" for 127.0.0.1 at 2014-11-25 17:11:35 +1100
Processing by SettingsController#plugin as HTML
  Parameters: {"id"=>"redmine_spent_time_in_issue_description"}
  Current user: admin (id=1)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/settings/_spent_time_settings.html.erb (4.1ms)
  Rendered settings/plugin.html.erb within layouts/admin (6.1ms)
Completed 500 Internal Server Error in 13.5ms

ActionView::Template::Error (undefined method `include?' on nil:NilClass.):
    31:       <td>
    32:         <select name="settings[display_columns][]" multiple style="width: 75px; height: 75px;">
    33:           <% %w( spentOn user hours comments activity).each do |column| %>
    34:             <option value="<%= column %>" <%= ( settings['display_columns'].include? column) ? "Selected" : "" %>><%= t("plugin_spent_time_in_issue.
"<< column )%></option>
    35:           <% end %>
    36:         </select>
    37:       </td>
  app/views/settings/plugin.html.erb:6:in `_app_views_settings_plugin_html_erb__2818416006110872778_420592'
  app/views/settings/plugin.html.erb:4:in `_app_views_settings_plugin_html_erb__2818416006110872778_420592'

or a ticket:

Started GET "/issues/40440" for 127.0.0.1 at 2014-11-25 16:37:19 +1100
Processing by IssuesController#show as HTML
  Parameters: {"id"=>"40440"}
  Current user: fconil (id=386)
Connecting to database specified by database.yml
  Rendered issues/_action_menu.html.erb (20.0ms)
Creating scope :sorted. Overwriting existing method User.sorted.
Creating scope :sorted. Overwriting existing method Group.sorted.
  Rendered plugins/redmine_contacts/app/views/deals_issues/_show.html.erb (23.0ms)
  Rendered plugins/redmine_contacts_helpdesk/app/views/issues/_ticket_data.html.erb (6.4ms)
  Rendered attachments/_links.html.erb (19.5ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (15.2ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (6.9ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (16.5ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (7.4ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (6.8ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (6.5ms)
  Rendered plugins/redmine_issue_checklist/app/views/issues/_checklist.html.erb (149.8ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/spent_time/_report.html.erb (21.6ms)
  Rendered issues/show.html.erb within layouts/base (788.5ms)
Completed 500 Internal Server Error in 3620.1ms

ActionView::Template::Error (undefined method `project_issue_time_entries_path' on an instance of #<Class:0x77df0>.):
    1: <% if User.current.allowed_to?(:view_time_entries, @project) and @issue.time_entries.present? %>
    2:   <hr />
    3:   <p><strong>Time Entries</strong> <%= link_to "see all #{@issue.time_entries.count} entries", project_issue_time_entries_path( @project , @issue ) if @issue.time_entries.count > Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i %> </p>
    4:
    5:   <table class="issue-spent-time-description">
    6:     <thead>
  lib/redmine/hook.rb:111:in `render_on'
  lib/redmine/hook.rb:61:in `call_hook'
  lib/redmine/hook.rb:61:in `call_hook'
  lib/redmine/hook.rb:58:in `call_hook'
  lib/redmine/hook.rb:158:in `call_hook'
  app/views/issues/show.html.erb:88:in `_app_views_issues_show_html_erb__3060823379866346025_469900'
  app/controllers/issues_controller.rb:128:in `show'
  app/controllers/issues_controller.rb:125:in `show'

I can reproduce the issue every time on one server, no matter which version of the plugin I am using (tried with version 1 and v2 hoping this would fix the issue).

Redmine info as follow:

Environment:
  Redmine version                2.6.0.stable.12119
  Ruby version                   2.1.0-p0 (2014-06-10) [x86_64-linux-gnu]
  Rails version                  3.2.19
  Environment                    production
  Database adapter               PostgreSQL

Any idea what could be causing this? I can't seem to figure out from the error logs alone.

TravisSpangle commented 9 years ago

The first error is happening because settings['display_columns'] is nil. This should be defined when the plugin is initially installed. If you configured no rows to be displayed that would also cause the error.

To resolve it just reinstall the plugin to reset 'display_columns' and you should no longer receive it. I need to include a validation that at least one value in that column is present.

I'm not sure why the second error is happening. That path, project_issue_time_entries_path, is native to Redmine.

frconil commented 9 years ago

Hi, just a quick update:

By reloading the DB from the prod environment (broken) into dev (working), I managed to reproduce the error. The rake routes, gemfile, codebase etc were 100% identical so it did make sense it was something in the DB.

TravisSpangle commented 9 years ago

OK, my last commit will prevent your first error from happening again. Please reopen if your issue isn't resolved. Thanks for reporting your errors!

frconil commented 9 years ago

Hi,

the error is still occurring. I can access the config panel for the plugin after installing v2 of the plugin, but now I get the following error when trying to display an issue:

Processing by IssuesController#show as HTML
  Parameters: {"id"=>"17413"}
  Current user: admin (id=1)
  Rendered issues/_action_menu.html.erb (5.6ms)
  Rendered plugins/redmine_contacts/app/views/deals_issues/_show.html.erb (2.5ms)
  Rendered plugins/redmine_contacts_helpdesk/app/views/issues/_ticket_data.html.erb (0.1ms)
  Rendered attachments/_links.html.erb (10.4ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (5.7ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (4.3ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (15.5ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (5.2ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (4.4ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (4.4ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (4.5ms)
  Rendered plugins/redmine_issue_checklist/app/views/issue_checklists/_checklist_item.html.erb (4.5ms)
  Rendered plugins/redmine_issue_checklist/app/views/issues/_checklist.html.erb (55.5ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/issues/_time_spent_report.html.erb (4.8ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/issues/show.html.erb within layouts/base (133.2ms)
Completed 500 Internal Server Error in 348.5ms

ActionView::Template::Error (undefined method `is_spent_on_shown' on an instance of #<Class:0x78c9c>.):
    15:   <tbody>
    16:     <% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each do |entry| %>
    17:       <tr>
    18:         <%= content_tag(:td, entry.spent_on.strftime("%m/%d/%Y") ) if is_spent_on_shown( entry ) %>
    19:         <%= content_tag(:td, link_to_user( entry.user )) if is_user_shown( entry ) %>
    20:         <%= content_tag(:td, report_time_spent( entry ) ) if is_report_time_shown( entry ) %>
    21:         <%= content_tag(:td, entry.comments ) if is_comment_shown( entry ) %>
  app/controllers/issues_controller.rb:128:in `show'
  app/controllers/issues_controller.rb:125:in `show'
frconil commented 9 years ago

FWIW I ran the rake migrate to uninstall the previous version of the plugin, restarted redmine, copied the newer version and ran the rake task to install it as per http://www.redmine.org/projects/redmine/wiki/Plugins before reporting this error.