backlogs / redmine_backlogs

A Redmine plugin for agile teams
https://backlogs.github.io/www/
GNU General Public License v2.0
773 stars 460 forks source link

Unprocessable Entity (invalid parent task) when changing task status via task board #1073

Open neusdan opened 10 years ago

neusdan commented 10 years ago

Hi,

i have a user story with 2 tasks. At creation time both tasks had as parent the user story. Then i changed task A to be the parent of task B. Trying now to changed the status of task B via task board fails with:

Processing by RbTasksController#update as */*
  Parameters: {"parent_issue_id"=>"12484", "status_id"=>"4", "next"=>"", "id"=>"17756", "project_id"=>"93", "authenticity_token"=>"xx+xx="}
  Current user: xxx(id=91)
Completed 422 Unprocessable Entity in 162.7ms

ActiveRecord::RecordInvalid (Validation failed: Parent task is invalid):
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/validations.rb:56:in `save!'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:264:in `block in save!'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:208:in `transaction'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:264:in `save!'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/persistence.rb:228:in `block in update_attributes!'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:208:in `transaction'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/persistence.rb:226:in `update_attributes!'
  plugins/redmine_backlogs/lib/backlogs_activerecord_mixin.rb:36:in `journalized_update_attributes!'
  plugins/redmine_backlogs/app/models/rb_task.rb:102:in `update_with_relationships'
  plugins/redmine_backlogs/app/controllers/rb_tasks_controller.rb:28:in `update'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/abstract_controller/base.rb:167:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/rendering.rb:10:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:502:in `_run__2354721887848103462__process_action__1981497538794881281__callbacks'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/abstract_controller/callbacks.rb:17:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/rescue.rb:29:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/notifications.rb:123:in `block in instrument'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/notifications.rb:123:in `instrument'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/abstract_controller/base.rb:121:in `process'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/abstract_controller/rendering.rb:45:in `process'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal.rb:203:in `dispatch'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_controller/metal.rb:246:in `block in action'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:73:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:36:in `call'
  vendor/bundle/ruby/2.1.0/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
  vendor/bundle/ruby/2.1.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
  vendor/bundle/ruby/2.1.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/routing/route_set.rb:608:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-openid-1.4.2/lib/rack/openid.rb:98:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/head.rb:14:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/flash.rb:242:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/cookies.rb:341:in `call'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/query_cache.rb:64:in `call'
  vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `_run__531458249529512090__call__2838209267794432053__callbacks'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  vendor/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/rack/logger.rb:32:in `call_app'
  vendor/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/rack/logger.rb:16:in `block in call'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/tagged_logging.rb:22:in `tagged'
  vendor/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/rack/logger.rb:16:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/request_id.rb:22:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
  vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.19/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
  vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.19/lib/action_dispatch/middleware/static.rb:63:in `call'
  vendor/bundle/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
  vendor/bundle/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
  vendor/bundle/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
  vendor/bundle/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
  vendor/bundle/ruby/2.1.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
  vendor/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/engine.rb:484:in `call'
  vendor/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/application.rb:231:in `call'
  vendor/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/railtie/configurable.rb:30:in `method_missing'
  passenger (4.0.49) lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
  passenger (4.0.49) lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
  passenger (4.0.49) lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
  passenger (4.0.49) lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'

Here you can see that the parent_issue_id"=>"12484 is wrong. Its the old parent.

When i changed the status via the issue page everything works fine: https://redmine.xxx.de/issues/17756

Processing by IssuesController#update_form as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx=", "issue"=>{"is_private"=>"0", "project_id"=>"93", "tracker_id"=>"5", "subject"=>"bla: bla", "description"=>"", "status_id"=>"4", "priority_id"=>"4", "assigned_to_id"=>"106", "category_id"=>"", "fixed_version_id"=>"620", "parent_issue_id"=>"17683", "start_date"=>"2014-08-06", "due_date"=>"", "estimated_hours"=>"1", "done_ratio"=>"0", "notes"=>"", "private_notes"=>"0", "lock_version"=>"11"}, "remaining_hours"=>"0.0", "last_journal_id"=>"61539", "id"=>"17756", "project_id"=>"xxxx"}
  Current user: xxx(id=91)
  Rendered issues/_form_custom_fields.html.erb (3.9ms)
  Rendered issues/_attributes.html.erb (46.3ms)
  Rendered issues/_form.html.erb (81.9ms)
  Rendered issues/update_form.js.erb (83.9ms)
Completed 200 OK in 140.8ms (Views: 69.4ms | ActiveRecord: 28.6ms)
Started PUT "/issues/17756" for 172.25.34.157 at 2014-09-25 10:29:58 +0200
Processing by IssuesController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"xx+xx=", "issue"=>{"is_private"=>"0", "project_id"=>"93", "tracker_id"=>"5", "subject"=>"xx: xx", "description"=>"", "status_id"=>"4", "priority_id"=>"4", "assigned_to_id"=>"106", "category_id"=>"", "fixed_version_id"=>"620", "parent_issue_id"=>"17683", "start_date"=>"2014-08-06", "due_date"=>"", "estimated_hours"=>"1.0", "done_ratio"=>"0", "notes"=>"", "private_notes"=>"0", "lock_version"=>"11"}, "remaining_hours"=>"0.0", "last_journal_id"=>"61539", "commit"=>"Submit", "id"=>"17756"}
  Current user: xxx(id=91)
  Rendered mailer/_issue.text.erb (4.8ms)
  Rendered mailer/issue_edit.text.erb within layouts/mailer (7.2ms)

Is it even supported to have a task to be the parent of another task?

sloncho commented 9 years ago

I get the same exception when a task is a subtask of another one. It tries to set the parent to be the story:

If I have Story1 -> T1 -> T2, and try to manipulate T2 in taskboard - change status, etc., the request it send to the server is: Parameters: {"parent_issue_id"=>"1234", "status_id"=>"2", ...

where 1234 is the Story1 id, not the T1 id. And this throws the above exception.