learningequality / learningequality/studio
ValueError: Cannot insert a node which has already been saved.
Open
Nobody has claimed this yet.
TAG: tech update / debt
- Dominant language
- Python
- Stars
- 191
- Forks
- 307
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 10
Description
During shallow copying, sometimes we seem to attempt to insert a node that has already been saved. Possible that this is a result of repeated application of a copy operation?
Sentry Issue: STUDIO-B88
ValueError: Cannot insert a node which has already been saved.
(4 additional frame(s) were not displayed)
...
File "contentcuration/db/models/manager.py", line 351, in copy_node
batch_size,
File "contentcuration/db/models/manager.py", line 385, in _copy
can_edit_source_channel,
File "contentcuration/db/models/manager.py", line 531, in _shallow_copy
self.insert_node(node_copy, target, position=position, save=False)
File "mptt/managers.py", line 72, in wrapped
return method(self, *args, **kwargs)
File "mptt/managers.py", line 522, in insert_node
raise ValueError(_('Cannot insert a node which has already been saved.'))
Task duplicate_nodes_task[ce3d48ec86a447acb58b4210f0b641c6] raised unexpected: ValueError('Cannot insert a node which has already been saved.',)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Sentry trace and contentcuration/db/models/manager.py at copy_node, _copy, and _shallow_copy, then inspect mptt/managers.py at insert_node. Reproduce or trace duplicate_nodes_task and determine why a saved node reaches insertion; done means the shallow-copy path no longer raises this ValueError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100