Defect #3705

Custom Values with a nil value cause HTTP error 500

Added by Jakob Skjerning about 13 years ago. Updated almost 13 years ago.

Status:ClosedStart date:2009-08-02
Priority:HighDue date:
Assignee:-% Done:


Category:Custom fields
Target version:0.8.6
Resolution:Fixed Affected version:0.8.4


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><
=>: <%=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

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, which is basically the same issue as this.

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

Associated revisions

Revision 2894
Added by Jean-Philippe Lang about 13 years ago

Fixed: Custom values with a nil value cause error on (project|account)/show (#3705).


#1 Updated by Jakob Skjerning about 13 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).

#2 Updated by Jean-Philippe Lang about 13 years ago

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

Fixed in r2894. Thanks.

#3 Updated by Jean-Philippe Lang almost 13 years ago

  • Status changed from Resolved to Closed

Merged in 0.8-stable in r2996.

Also available in: Atom PDF