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

fix: always define a student_data_store to prevent errors on XBlock load [FC-0076] #36226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading