Project

General

Profile

Actions

Defect #3705

closed

Custom Values with a nil value cause HTTP error 500

Added by Jakob Skjerning over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
High
Assignee:
-
Category:
Custom fields
Target version:
Start date:
2009-08-02
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

I recently upgraded my Redmine installation from r2264 to r2835. The upgrade and database migration went without a hitch.

However, most - but not all - of my project pages stopped working. The log states:

bc. ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?) on line #12 of app/views/projects/show.rhtml:
9: <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") ></li>
10: <
end >
11: <
@project.custom_values.each do |custom_value| >
12: <
if !custom_value.value.empty? >
13: <li><
= custom_value.custom_field.name%>: <%=h show_value(custom_value) ></li>
14: <
end >
15: <
end %>

Digging into my data it appears that all the Projects whose page have stopped working have a bunch of CustomFields with a value of nil:

bc. >> Project.first.custom_values
=> [#<CustomValue id: 234, customized_type: "Project", customized_id: 1, custom_field_id: 4, value: nil>, #<CustomValue id: 235, customized_type: "Project", customized_id: 1, custom_field_id: 5, value: nil>]

Both of those custom fields appear to have been added by the Redmine Hoptoad Server plugin at http://github.com/yeah/redmine_hoptoad_server/tree/master.

Anyways, seeing as there are no validations in RedMine on CustomValue preventing nil-values from being stored in the database, the projects/show.rhtml view is making unsafe assumptions. The attached patch adds a safeguard for the assumption.

The patch also fixes the issue reported in http://www.redmine.org/boards/2/topics/5872, which is basically the same issue as this.


Files

custom_values_can_be_nil.diff (2.72 KB) custom_values_can_be_nil.diff Jakob Skjerning, 2009-08-02 18:38
Actions #1

Updated by Jakob Skjerning over 14 years ago

If you, as a Redmine user, want to work around this issue, the following method appears to be working:

1. Go to your Project administration area under Administration > Projects
2. Visit each project that has the above issue.
3. Click "Save".

This should fix the above issue (by replacing the nil-values with empty strings).

Actions #2

Updated by Jean-Philippe Lang over 14 years ago

  • Status changed from New to Resolved
  • Target version set to 0.8.6
  • Resolution set to Fixed

Fixed in r2894. Thanks.

Actions #3

Updated by Jean-Philippe Lang over 14 years ago

  • Status changed from Resolved to Closed

Merged in 0.8-stable in r2996.

Actions

Also available in: Atom PDF