Defect #33930

500 error when attempting to create custom field enumeration with empty name

Added by Felix Schäfer almost 2 years ago. Updated over 1 year ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:


Category:Custom fields
Target version:4.2.0
Resolution:Fixed Affected version:4.1.1


When editing the list of possible values for a key/value custom field type, clicking "Add" with the field empty will lead to a HTTP 500 error from Redmine. An example stack trace is attached. The error is confirmed on current master.

It should at least be fixed that Redmine does not create an HTTP 500 error, an error message that the value must not be empty would be better.

Started POST "/custom_fields/1/enumerations" for ::1 at 2020-08-30 17:47:21 +0200
Processing by CustomFieldEnumerationsController#create as JS
  Parameters: {"utf8"=>"✓", "custom_field_enumeration"=>{"name"=>""}, "commit"=>"Add", "custom_field_id"=>"1"}
  Token Update All (2.5ms)  UPDATE `tokens` SET `tokens`.`updated_on` = '2020-08-30 17:47:21' WHERE `tokens`.`user_id` = 1 AND `tokens`.`value` = '<redacted>' AND `tokens`.`action` = 'session'
   (0.3ms)  SELECT MAX(`settings`.`updated_on`) FROM `settings`
  User Load (0.3ms)  SELECT  `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`status` = 1 AND `users`.`id` = 1 LIMIT 1
  Current user: admin (id=1)
  CustomField Load (0.3ms)  SELECT  `custom_fields`.* FROM `custom_fields` WHERE `custom_fields`.`id` = 1 LIMIT 1
   (0.3ms)  BEGIN
   (0.2ms)  ROLLBACK
  Rendering custom_field_enumerations/create.js.erb
  Rendering custom_field_enumerations/index.html.erb
  CustomFieldEnumeration Load (0.4ms)  SELECT `custom_field_enumerations`.* FROM `custom_field_enumerations` WHERE `custom_field_enumerations`.`custom_field_id` = 1 ORDER BY `custom_field_enumerations`.`position` ASC
  Rendered custom_field_enumerations/index.html.erb (8.8ms)
  Rendered custom_field_enumerations/create.js.erb (13.7ms)
Completed 500 Internal Server Error in 100ms (ActiveRecord: 4.4ms)

ActionView::Template::Error (No route matches {:action=>"update", :controller=>"custom_field_enumerations", :custom_field_id=>"1", :id=>nil}, missing required keys: [:id]):
    14:         <%= check_box_tag "custom_field_enumerations[#{}][active]", 1, %>
    15:         <%= l(:field_active) %>
    16:       </label>
    17:       <%= delete_link custom_field_enumeration_path(@custom_field, value) %>
    18:     </li>
    19:   <% end %>
    20:   </ul>

app/views/custom_field_enumerations/index.html.erb:17:in `block (2 levels) in _app_views_custom_field_enumerations_index_html_erb___3882666770216567044_70211539369080'
app/views/custom_field_enumerations/index.html.erb:7:in `each_with_index'
app/views/custom_field_enumerations/index.html.erb:7:in `block in _app_views_custom_field_enumerations_index_html_erb___3882666770216567044_70211539369080'
app/views/custom_field_enumerations/index.html.erb:4:in `_app_views_custom_field_enumerations_index_html_erb___3882666770216567044_70211539369080'
app/views/custom_field_enumerations/create.js.erb:1:in `_app_views_custom_field_enumerations_create_js_erb__3749928945083050900_70211553777600'
lib/redmine/sudo_mode.rb:64:in `sudo_mode'

33930.diff Magnifier (3.59 KB) Kevin Fischer, 2020-09-21 10:25

33930-validation.png (48 KB) Go MAEDA, 2020-11-28 07:33

Associated revisions

Revision 20583
Added by Go MAEDA over 1 year ago

500 error when attempting to create custom field enumeration with empty name (#33930).

Patch by Kevin Fischer.


#1 Updated by Go MAEDA almost 2 years ago

  • Status changed from New to Confirmed

#2 Updated by Kevin Fischer almost 2 years ago

Here is a patch written by goh, rbtgr and me.

#3 Updated by Go MAEDA almost 2 years ago

  • Target version set to Candidate for next major release

#4 Updated by Go MAEDA over 1 year ago

  • File 33930-validation.png added
  • Target version changed from Candidate for next major release to 4.2.0

Validation errors are now handled properly with the patch. Setting the target version to 4.2.0.

#5 Updated by Go MAEDA over 1 year ago

  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for fixing the issue.

Also available in: Atom PDF