Skip to content

Commit f3fc0ec

Browse files
rpenidotonybusa
authored andcommitted
fix: error when loading survey block without user in new runtime (openedx#36226)
* fix: always define a student_data_store to prevent errors on XBlock load * chore: bump xblock version to 5.1.2
1 parent a739122 commit f3fc0ec

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

openedx/core/djangoapps/xblock/runtime/runtime.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from web_fragments.fragment import Fragment
1919
from xblock.core import XBlock
2020
from xblock.exceptions import NoSuchServiceError
21-
from xblock.field_data import FieldData, SplitFieldData
21+
from xblock.field_data import DictFieldData, FieldData, SplitFieldData
2222
from xblock.fields import Scope, ScopeIds
2323
from xblock.runtime import IdReader, KvsFieldData, MemoryIdManager, Runtime
2424

@@ -351,8 +351,10 @@ def _init_field_data_for_block(self, block: XBlock) -> FieldData:
351351
Initialize the FieldData implementation for the specified XBlock
352352
"""
353353
if self.user is None:
354-
# No user is specified, so we want to throw an error if anything attempts to read/write user-specific fields
355-
student_data_store = None
354+
# No user is specified, so we want to ignore any user-specific data. We cannot throw an
355+
# error here because the XBlock loading process will write to the user_state if we have
356+
# mutable fields.
357+
student_data_store = DictFieldData({})
356358
elif self.user.is_anonymous:
357359
# This is an anonymous (non-registered) user:
358360
assert isinstance(self.user_id, str) and self.user_id.startswith("anon")

requirements/edx/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ wheel==0.45.1
12521252
# via django-pipeline
12531253
wrapt==1.17.2
12541254
# via -r requirements/edx/kernel.in
1255-
xblock[django]==5.1.1
1255+
xblock[django]==5.1.2
12561256
# via
12571257
# -r requirements/edx/kernel.in
12581258
# acid-xblock

requirements/edx/development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2239,7 +2239,7 @@ wrapt==1.17.2
22392239
# via
22402240
# -r requirements/edx/doc.txt
22412241
# -r requirements/edx/testing.txt
2242-
xblock[django]==5.1.1
2242+
xblock[django]==5.1.2
22432243
# via
22442244
# -r requirements/edx/doc.txt
22452245
# -r requirements/edx/testing.txt

requirements/edx/doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ wheel==0.45.1
15731573
# django-pipeline
15741574
wrapt==1.17.2
15751575
# via -r requirements/edx/base.txt
1576-
xblock[django]==5.1.1
1576+
xblock[django]==5.1.2
15771577
# via
15781578
# -r requirements/edx/base.txt
15791579
# acid-xblock

requirements/edx/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ wheel==0.45.1
16631663
# django-pipeline
16641664
wrapt==1.17.2
16651665
# via -r requirements/edx/base.txt
1666-
xblock[django]==5.1.1
1666+
xblock[django]==5.1.2
16671667
# via
16681668
# -r requirements/edx/base.txt
16691669
# acid-xblock

0 commit comments

Comments
 (0)