learningequality / learningequality/studio
Inconsistent state of completion criteria in contentnode due to backend validation errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 191
- Forks
- 307
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 10
Description
Observed behavior
When a user attempts to update the completion criteria of a ContentNode, the system fails to revert to the last valid state if a backend validation error occurs. This results in an unexpected state of completion criteria, which does not reflect the last correct configuration.
Expected behavior
Frontend should have the last correct state of completion criteria (we would want to revert the optimistic changes) in such a way that the user knows that other changes have overridden theirs.
User-facing consequences
Inconsistent/Incorrect state of completion criteria for a Contentnode while collaborating.
Errors and logs
[2024-08-20 08:05:32,634: ERROR/ForkPoolWorker-1] [ErrorDetail(string='["Completion criteria doesn\'t conform to schema", "object doesn\'t satisfy \'anyOf\' conditions"]', code=None)]
Traceback (most recent call last):
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/contentnode.py", line 414, in _check_completion_criteria
completion_criteria_validator.validate(completion_criteria, kind)
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/constants/completion_criteria.py", line 97, in validate
raise e
django.core.exceptions.ValidationError: ["Completion criteria doesn't conform to schema", "object doesn't satisfy 'anyOf' conditions"]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/base.py", line 864, in update_from_changes
self.perform_bulk_update(serializer)
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/base.py", line 851, in perform_bulk_update
serializer.save()
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/base.py", line 364, in save
instance = super(BulkListSerializer, self).save(**kwargs)
File "/home/ozer/.pyenv/versions/3.10.13/envs/studio-py3.10/lib/python3.10/site-packages/rest_framework/serializers.py", line 753, in save
self.instance = self.update(self.instance, validated_data)
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/contentnode.py", line 250, in update
all_objects = super(ContentNodeListSerializer, self).update(
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/base.py", line 311, in update
instance = self.child.update(obj, obj_validated_data)
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/contentnode.py", line 445, in update
self._check_completion_criteria(validated_data.get("kind", instance.kind_id), validated_data.get("complete", instance.complete), validated_data)
File "/home/ozer/workspace/LE/studio/contentcuration/contentcuration/viewsets/contentnode.py", line 418, in _check_completion_criteria
raise ValidationError(e)
rest_framework.exceptions.ValidationError: [ErrorDetail(string='["Completion criteria doesn\'t conform to schema", "object doesn\'t satisfy \'anyOf\' conditions"]', code=None)]
Additional information
follow up #3879
Steps to reproduce the issue
- Open studio in two different browsers.
- Login with admin user and userC.
- Simultaneously open same ContentNode with content kind html5 in both tabs.
- First change the completion criteria to aprrox time mode.
- In one tab change the model to refrence .
- Simultaneously on other tab change the time threshold to valid different value.
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 contentcuration/viewsets/contentnode.py, especially _check_completion_criteria and update, then follow the bulk-update flow in contentcuration/viewsets/base.py and validation in contentcuration/constants/completion_criteria.py. Reproduce the two-browser scenario and verify that a backend validation failure restores the last valid completion criteria state while making the overriding change clear to the user.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100