Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent state of completion criteria in contentnode due to backend validation errors #4665

Open
ozer550 opened this issue Aug 22, 2024 · 0 comments

Comments

@ozer550
Copy link
Member

ozer550 commented Aug 22, 2024

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

  1. Open studio in two different browsers.
  2. Login with admin user and userC.
  3. Simultaneously open same ContentNode with content kind html5 in both tabs.
  4. First change the completion criteria to aprrox time mode.
  5. In one tab change the model to refrence .
  6. Simultaneously on other tab change the time threshold to valid different value.
@ozer550 ozer550 changed the title Inconsistent state of completion Criteria in contentNode Due to backend validation errors Inconsistent state of completion criteria in contentnode due to backend validation errors Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant