Defect #17580


After copying a task, setting the parent as the orignal task's parent triggers an error

Added by Olivier Houdas almost 10 years ago. Updated over 8 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Affected version:


Steps for repro:
1. Create an issue (1), and add a sub-issue (2) to it
2. Copy this sub-issue (creates issue 3)
3. Edit issue 3, set issue 1 as its parent
Result: We get an error that Parent Issue is invalid
4. Copy (2), and while in edit mode, define issue 1 as the parent
Result: this relationship is accepted
5. Create sub-issue (4) of issue 1
6. Display issue 4, add issue 2 as a related issue
Result: this relationship is accepted

Expected result: the behavior should be consistent. As far as I'm concerned, I do not see what would justify that "relations" would be forbidden inside the parent-children tree, so the faulty behavior would be the first result (Parent issue invalid) but I might be missing some cases.

Notes :
1) This is related to #12893 (obviously on purpose, see line 216 of app/models/issue.rb:
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")

2) The current behaviour for 1st result is on purpose: the error message is triggered by line 600 of issue.rb:
elsif (@parent_issue != parent) && (all_dependent_issues.include?(@parent_issue) || @parent_issue.all_dependent_issues.include?(self))

which definitely parses parents, children, cousins, etc., but also related issues.


17580-RM-3.1.1.patch (2.17 KB) 17580-RM-3.1.1.patch Olivier Houdas, 2015-10-20 17:21

Related issues

Related to Redmine - Defect #12893: Copying an issue does not copy parent task idClosedJean-Philippe Lang

Related to Redmine - Defect #13654: Can't set parent issue when issue relations among child issues are presentClosedJean-Philippe Lang

Actions #1

Updated by Toshi MARUYAMA almost 10 years ago

  • Related to Defect #12893: Copying an issue does not copy parent task id added
Actions #2

Updated by Olivier Houdas over 8 years ago

I fell on this issue again one year later, and so I decided to have a deeper look at the situation.

If we consider that

     /      \
Child1 <--> Child2

is a circular relationship, then it should be tested when adding a relation as well, and not only when modifying the parent id.
For this, we should add a test in /app/models/issue_relation.rb.

Now, when there is no relation added (Redmine configuration setting set to Do not link copied issues), we should not cancel the copy of the parent_id, as mentioned in #12893. For this, I suggest to take this setting into account and copy the parent_id attribute conditionally.

I attached a patch which implements those remarks.

You will note that the failure of adding the link after saving the copied issue (which comes after validation, and therefore relies on a different validation than when changing the parent_id), results only in an ERROR in the log, and not in a flashed error. Feel free to modify this behavior if you feel this is necessary.

Could this come into a release soon?

Actions #3

Updated by Toshi MARUYAMA over 8 years ago

  • Related to Defect #13654: Can't set parent issue when issue relations among child issues are present added
Actions #4

Updated by Jean-Philippe Lang over 8 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 3.3.0
  • Resolution set to Fixed

This is fixed as part of #13654, test added in r15057.


Also available in: Atom PDF