Skip to content

Commit

Permalink
fix: error when loading survey block without user in new runtime (#36226
Browse files Browse the repository at this point in the history
)

* fix: always define a student_data_store to prevent errors on XBlock load

* chore: bump xblock version to 5.1.2
  • Loading branch information
rpenido authored Feb 12, 2025
1 parent 9ae7566 commit a8ad9c8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions openedx/core/djangoapps/xblock/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.exceptions import NoSuchServiceError
from xblock.field_data import FieldData, SplitFieldData
from xblock.field_data import DictFieldData, FieldData, SplitFieldData
from xblock.fields import Scope, ScopeIds
from xblock.runtime import IdReader, KvsFieldData, MemoryIdManager, Runtime

Expand Down Expand Up @@ -351,8 +351,10 @@ def _init_field_data_for_block(self, block: XBlock) -> FieldData:
Initialize the FieldData implementation for the specified XBlock
"""
if self.user is None:
# No user is specified, so we want to throw an error if anything attempts to read/write user-specific fields
student_data_store = None
# No user is specified, so we want to ignore any user-specific data. We cannot throw an
# error here because the XBlock loading process will write to the user_state if we have
# mutable fields.
student_data_store = DictFieldData({})
elif self.user.is_anonymous:
# This is an anonymous (non-registered) user:
assert isinstance(self.user_id, str) and self.user_id.startswith("anon")
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ wheel==0.45.1
# via django-pipeline
wrapt==1.17.2
# via -r requirements/edx/kernel.in
xblock[django]==5.1.1
xblock[django]==5.1.2
# via
# -r requirements/edx/kernel.in
# acid-xblock
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ wrapt==1.17.2
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
xblock[django]==5.1.1
xblock[django]==5.1.2
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ wheel==0.45.1
# django-pipeline
wrapt==1.17.2
# via -r requirements/edx/base.txt
xblock[django]==5.1.1
xblock[django]==5.1.2
# via
# -r requirements/edx/base.txt
# acid-xblock
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ wheel==0.45.1
# django-pipeline
wrapt==1.17.2
# via -r requirements/edx/base.txt
xblock[django]==5.1.1
xblock[django]==5.1.2
# via
# -r requirements/edx/base.txt
# acid-xblock
Expand Down

0 comments on commit a8ad9c8

Please sign in to comment.