Project

General

Profile

Actions

Defect #33930

closed

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

Added by Felix Schäfer over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Custom fields
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

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[#{value.id}][active]", 1, value.active? %>
    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'

Files

33930.diff (3.59 KB) 33930.diff Kevin Fischer, 2020-09-21 10:25
33930-validation.png (48 KB) 33930-validation.png Go MAEDA, 2020-11-28 07:33
Actions #1

Updated by Go MAEDA over 4 years ago

  • Status changed from New to Confirmed
Actions #2

Updated by Kevin Fischer over 4 years ago

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

Actions #3

Updated by Go MAEDA about 4 years ago

  • Target version set to Candidate for next major release
Actions #4

Updated by Go MAEDA about 4 years ago

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

Actions #5

Updated by Go MAEDA about 4 years 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.

Actions

Also available in: Atom PDF