Skip to content

Forum bug: Moving a thread between categories #3109

@Lezek123

Description

@Lezek123

The current move_thread_to_category implementation is not updating thread.category_id, which is causing multiple issues when moving a thread between categories.

For example, let's assume we have two categories: 1 and 2, and a single thread in category 1

  1. We move the thread from category 1 to category 2. This works as expected so far, the threadById map is updated and the num_direct_threads counter for each category is correct (0 and 1 respectively)
  2. We move the thread from category 2 back to category 1. Because thread.category_id is still 1 after the first step, the thread is not actually removed from category 2 and ends up duplicated (appears in both categories). Furthermore, the num_direct_threads of category 1 is first decremented and then incremented, causing it to remain at 0.
  3. We move the thread from category 1 to category 2 again. The thread is now removed from category 1 and the num_direct_threads in category 1 is decremented again, causing the counter to overflow to 4294967295. The num_direct_threads is incremented causing it to become 2, which is also invalid.

┆Issue is synchronized with this Asana task by Unito

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions