diff --git a/cms/lib/xblock/tagging/test.py b/cms/lib/xblock/tagging/test.py
index be8bb62a6454..6e0607dfd266 100644
--- a/cms/lib/xblock/tagging/test.py
+++ b/cms/lib/xblock/tagging/test.py
@@ -11,7 +11,7 @@
from django.test.client import RequestFactory
from lxml import etree
from opaque_keys.edx.asides import AsideUsageKeyV1, AsideUsageKeyV2
-from xblock.fields import ScopeIds
+from opaque_keys.edx.keys import CourseKey
from xblock.runtime import DictKeyValueStore, KvsFieldData
from xblock.test.tools import TestRuntime
@@ -31,6 +31,7 @@
BlockFactory,
CourseFactory,
)
+from xmodule.tests import make_test_scope_ids # pylint: disable=wrong-import-order
@ddt.ddt
@@ -122,10 +123,12 @@ def test_aside_contains_tags(self):
"""
Checks that available_tags list is not empty
"""
- sids = ScopeIds(user_id="bob",
- block_type="bobs-type",
- def_id="definition-id",
- usage_id="usage-id")
+ sids = make_test_scope_ids(
+ "bobs-type",
+ "usage-id",
+ course_key=CourseKey.from_string("course-v1:myOrg+myCourse+myRun"),
+ user_id="bob",
+ )
key_store = DictKeyValueStore()
field_data = KvsFieldData(key_store)
runtime = TestRuntime(services={'field-data': field_data})
diff --git a/lms/djangoapps/courseware/tests/test_discussion_xblock.py b/lms/djangoapps/courseware/tests/test_discussion_xblock.py
index a94286156d73..5bdd012483ac 100644
--- a/lms/djangoapps/courseware/tests/test_discussion_xblock.py
+++ b/lms/djangoapps/courseware/tests/test_discussion_xblock.py
@@ -28,6 +28,7 @@
from openedx.core.djangoapps.discussions.services import DiscussionConfigService
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import BlockFactory, ToyCourseFactory
+from xmodule.tests import make_test_scope_ids
from xmodule.tests.helpers import mock_render_template
@@ -52,8 +53,7 @@ def setUp(self):
self.data = DictFieldData({
'discussion_id': self.discussion_id
})
- scope_ids = mock.Mock()
- scope_ids.usage_id.context_key = self.course_id
+ scope_ids = make_test_scope_ids('discussion', 'test_discussion', course_key=self.course_id)
self.block = DiscussionXBlock(
self.runtime,
field_data=self.data,
diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py
index 3af319e778d9..7f431be31f76 100644
--- a/lms/djangoapps/courseware/tests/test_video_mongo.py
+++ b/lms/djangoapps/courseware/tests/test_video_mongo.py
@@ -101,7 +101,7 @@ def instantiate_block(**field_data):
usage_key = course_key.make_usage_key('video', 'SampleProblem')
return system.construct_xblock_from_class(
VideoBlock,
- scope_ids=ScopeIds(None, None, usage_key, usage_key),
+ scope_ids=ScopeIds(None, 'video', usage_key, usage_key),
field_data=DictFieldData(field_data),
)
diff --git a/openedx/core/djangoapps/video_config/tests/test_services.py b/openedx/core/djangoapps/video_config/tests/test_services.py
index ea446717d4e4..20612b070b5d 100644
--- a/openedx/core/djangoapps/video_config/tests/test_services.py
+++ b/openedx/core/djangoapps/video_config/tests/test_services.py
@@ -28,7 +28,7 @@ def instantiate_video_block(self, **field_data):
usage_key = course_key.make_usage_key('video', 'SampleProblem')
return system.construct_xblock_from_class(
VideoBlock,
- scope_ids=ScopeIds(None, None, usage_key, usage_key),
+ scope_ids=ScopeIds(None, 'video', usage_key, usage_key),
field_data=DictFieldData(field_data),
)
diff --git a/openedx/core/djangoapps/xblock/runtime/runtime.py b/openedx/core/djangoapps/xblock/runtime/runtime.py
index dc5d0696ee62..2a437a2e1360 100644
--- a/openedx/core/djangoapps/xblock/runtime/runtime.py
+++ b/openedx/core/djangoapps/xblock/runtime/runtime.py
@@ -19,7 +19,7 @@
from xblock.exceptions import NoSuchServiceError
from xblock.field_data import DictFieldData, FieldData, SplitFieldData
from xblock.fields import Scope, ScopeIds
-from xblock.runtime import IdReader, KvsFieldData, MemoryIdManager, Runtime
+from xblock.runtime import IdReader, KvsFieldData, Runtime
from common.djangoapps.edxmako.services import MakoService
from common.djangoapps.static_replace.services import ReplaceURLService
@@ -130,7 +130,7 @@ def __init__(
),
default_class=None,
select=None,
- id_generator=MemoryIdManager(), # We don't really use id_generator until we need to support asides
+ id_generator=None, # We won't need an id_generator until we need to support asides
)
assert student_data_mode in (StudentDataMode.Ephemeral, StudentDataMode.Persisted)
self.authored_data_mode = authored_data_mode
diff --git a/pyproject.toml b/pyproject.toml
index eed96a41e853..dac3ac1404b0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -258,6 +258,10 @@ default-groups = [] # explicit, not omitted -- uv's own default-groups fallback
# tested at once, list them here as one set, e.g. [[{ group = "django52" }, { group = "django60" }]],
# otherwise uv refuses to resolve both into one lock.
conflicts = []
+# TEMP: Kyle's XBlock fork (see [tool.uv.sources] below) has no git tags, so setuptools-scm
+# would build it as version 0.0. Give the build a version explicitly. Remove together
+# with the xblock source once https://github.com/openedx/XBlock/pull/809 is released.
+extra-build-variables = { xblock = { SETUPTOOLS_SCM_PRETEND_VERSION = "6.3.5" } }
# DO NOT EDIT constraint-dependencies DIRECTLY.
# This list is managed by `edx_lint write_uv_constraints` and will be
@@ -290,6 +294,12 @@ constraint-dependencies = [
"pytest<9.2.0",
"lti-consumer-xblock==11.5.1",
]
+
+[tool.uv.sources]
+# TEMP: test against the unreleased XBlock change that mandates OpaqueKey scope IDs
+# (https://github.com/openedx/XBlock/pull/809). Remove once it is released to PyPI.
+xblock = { git = "https://github.com/kdmccormick/XBlock.git", branch = "kdmccormick/scope-id-types" }
+
[tool.edx_lint]
uv_constraints = [
# Date: 2025-10-07
diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt
index 6edeba971177..080262828d17 100644
--- a/requirements/edx/base.txt
+++ b/requirements/edx/base.txt
@@ -1288,7 +1288,7 @@ wrapt==2.5.2
# via
# openedx-platform
# xblocks-core
-xblock==6.3.5
+xblock @ git+https://github.com/kdmccormick/XBlock.git@ad65b7255ab68b3f274c048ea8a79a91a129aea3
# via
# acid-xblock
# crowdsourcehinter-xblock
diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt
index 155d72ea6692..ff0723b9a8ba 100644
--- a/requirements/edx/development.txt
+++ b/requirements/edx/development.txt
@@ -1572,7 +1572,7 @@ wrapt==2.5.2
# via
# openedx-platform
# xblocks-core
-xblock==6.3.5
+xblock @ git+https://github.com/kdmccormick/XBlock.git@ad65b7255ab68b3f274c048ea8a79a91a129aea3
# via
# acid-xblock
# crowdsourcehinter-xblock
diff --git a/uv.lock b/uv.lock
index 53f025cee7fc..fbd439e127d5 100644
--- a/uv.lock
+++ b/uv.lock
@@ -4972,7 +4972,7 @@ requires-dist = [
{ name = "web-fragments" },
{ name = "webob" },
{ name = "wrapt" },
- { name = "xblock", extras = ["django"] },
+ { name = "xblock", extras = ["django"], git = "https://github.com/kdmccormick/XBlock.git?branch=kdmccormick%2Fscope-id-types" },
{ name = "xss-utils" },
]
@@ -8120,7 +8120,7 @@ wheels = [
[[package]]
name = "xblock"
version = "6.3.5"
-source = { registry = "https://pypi.org/simple" }
+source = { git = "https://github.com/kdmccormick/XBlock.git?branch=kdmccormick%2Fscope-id-types#ad65b7255ab68b3f274c048ea8a79a91a129aea3" }
dependencies = [
{ name = "edx-opaque-keys" },
{ name = "fs" },
@@ -8133,10 +8133,6 @@ dependencies = [
{ name = "simplejson" },
{ name = "webob" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/5b/c2/26b295d703beeb34e1b051d5842699ef80814163faa96d0f1875464092e5/xblock-6.3.5.tar.gz", hash = "sha256:e2ca8389b4d7ca414bfb1bceb3888e7d78d7223acb684d369c1e76455c64874f", size = 1228312, upload-time = "2026-11-02T19:02:15.24Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/e4/ff/76a4984d5632f0e270caca666d4868dff88c4d5e1dd96fc471540afe1f61/xblock-6.3.5-py3-none-any.whl", hash = "sha256:d57d6b162645fa5574deb3d3111914d01aaeddea78aface97e621183349d3f2f", size = 160955, upload-time = "2026-11-02T19:02:13.712Z" },
-]
[package.optional-dependencies]
django = [
diff --git a/xmodule/modulestore/tests/test_api.py b/xmodule/modulestore/tests/test_api.py
index a7e15ee2c209..85e1018e65c4 100644
--- a/xmodule/modulestore/tests/test_api.py
+++ b/xmodule/modulestore/tests/test_api.py
@@ -18,6 +18,7 @@
get_root_module_name,
get_xblock_root_module_name,
)
+from xmodule.tests import make_test_scope_ids
def test_get_root_module_name():
@@ -43,7 +44,7 @@ def test_get_xblock_root_module_name():
})
runtime = TestRuntime(Mock(), mixins=[TestSimpleMixin], services={'field-data': field_data})
- mixed_done_xblock = runtime.construct_xblock_from_class(DoneXBlock, Mock())
+ mixed_done_xblock = runtime.construct_xblock_from_class(DoneXBlock, make_test_scope_ids('done'))
assert mixed_done_xblock.__module__ == 'xblock.core'
assert mixed_done_xblock.unmixed_class == DoneXBlock, 'The unmixed_class property retains the original property.'
diff --git a/xmodule/modulestore/tests/test_inheritance.py b/xmodule/modulestore/tests/test_inheritance.py
index 11fe96210f58..bf866d3bd272 100644
--- a/xmodule/modulestore/tests/test_inheritance.py
+++ b/xmodule/modulestore/tests/test_inheritance.py
@@ -9,10 +9,10 @@
import ddt
from django.utils.timezone import now, timedelta
from xblock.core import XBlock
-from xblock.fields import ScopeIds
from xblock.test.tools import TestRuntime
from xmodule.modulestore.inheritance import InheritanceMixin
+from xmodule.tests import make_test_scope_ids
class TestXBlock(XBlock):
@@ -36,7 +36,7 @@ def setUp(self):
Mock(entry_point=XBlock.entry_point), mixins=[InheritanceMixin], services={'field-data': {}}
)
self.xblock = runtime.construct_xblock_from_class(
- TestXBlock, ScopeIds('user', 'TestXBlock', 'def_id', 'usage_id')
+ TestXBlock, make_test_scope_ids('TestXBlock', user_id='user')
)
super().setUp()
diff --git a/xmodule/modulestore/tests/test_semantics.py b/xmodule/modulestore/tests/test_semantics.py
index 9b5899ac00d5..799d3baef42f 100644
--- a/xmodule/modulestore/tests/test_semantics.py
+++ b/xmodule/modulestore/tests/test_semantics.py
@@ -276,12 +276,12 @@ def _do_create(self, block_type, with_asides=False):
block.fields[test_data.field_name].write_to(block, initial_field_value)
asides = []
if with_asides:
- asides = self._prepare_asides(self.course.scope_ids.usage_id)
+ asides = self._prepare_asides(self.course.scope_ids)
self.store.update_item(block, ModuleStoreEnum.UserID.test, asides=asides, allow_not_found=True)
else:
asides = []
if with_asides:
- asides = self._prepare_asides(self.course.scope_ids.usage_id)
+ asides = self._prepare_asides(self.course.scope_ids)
self.store.create_child(
user_id=ModuleStoreEnum.UserID.test,
parent_usage_key=self.course.scope_ids.usage_id,
diff --git a/xmodule/modulestore/tests/test_xml_importer.py b/xmodule/modulestore/tests/test_xml_importer.py
index 8f18907f2c2f..228b6594c361 100644
--- a/xmodule/modulestore/tests/test_xml_importer.py
+++ b/xmodule/modulestore/tests/test_xml_importer.py
@@ -13,14 +13,14 @@
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
from path import Path as path
-from xblock.fields import List, Scope, ScopeIds, String
+from xblock.fields import List, Scope, String
from xblock.runtime import DictKeyValueStore, KvsFieldData, Runtime
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.modulestore.tests.mongo_connection import MONGO_HOST, MONGO_PORT_NUM
from xmodule.modulestore.xml_importer import StaticContentImporter, _update_and_import_block, _update_block_location
-from xmodule.tests import DATA_DIR
+from xmodule.tests import DATA_DIR, make_test_scope_ids
from xmodule.x_module import XModuleMixin
OPEN_BUILTIN = 'builtins.open'
@@ -156,7 +156,7 @@ def setUp(self):
"""
self.runtime = mock.MagicMock(Runtime)
self.field_data = KvsFieldData(kvs=DictKeyValueStore())
- self.scope_ids = ScopeIds('Bob', 'mutablestubxblock', '123', 'import')
+ self.scope_ids = make_test_scope_ids('mutablestubxblock', 'import', user_id='Bob')
self.xblock = StubXBlockWithMutableFields(self.runtime, self.field_data, self.scope_ids)
self.fake_children_locations = [
diff --git a/xmodule/tests/__init__.py b/xmodule/tests/__init__.py
index ded0dfc43db7..b9e32cbd0205 100644
--- a/xmodule/tests/__init__.py
+++ b/xmodule/tests/__init__.py
@@ -126,7 +126,7 @@ def get_test_system(
descriptor_system = get_test_descriptor_system(id_reader=id_manager, id_generator=id_manager)
if not user:
- user = Mock(name='get_test_system.user', is_staff=False)
+ user = Mock(name='get_test_system.user', is_staff=False, id=1)
if not user_location:
user_location = Mock(name='get_test_system.user_location')
user_service = StubUserService(
@@ -185,7 +185,7 @@ def prepare_block_runtime(
"""
if not user:
- user = Mock(name='get_test_system.user', is_staff=False)
+ user = Mock(name='get_test_system.user', is_staff=False, id=1)
if not user_location:
user_location = Mock(name='get_test_system.user_location')
user_service = StubUserService(
@@ -241,6 +241,18 @@ def get_block(block):
return runtime
+def make_test_scope_ids(block_type, block_id='test_block', course_key=None, user_id=None):
+ """
+ Return valid ScopeIds for a test block of the given type.
+
+ XBlock validates ScopeIds, so tests can no longer pass a Mock or None for them.
+ """
+ id_generator = CourseLocationManager(course_key or CourseKey.from_string('org/course/run'))
+ def_id = id_generator.create_definition(block_type, block_id)
+ usage_id = id_generator.create_usage(def_id)
+ return ScopeIds(user_id, block_type, def_id, usage_id)
+
+
def get_test_descriptor_system(render_template=None, **kwargs):
"""
Construct a test ModuleStoreRuntime instance.
diff --git a/xmodule/tests/test_annotatable_block.py b/xmodule/tests/test_annotatable_block.py
index d1ea0087b4b1..bd4b2969a5fd 100644
--- a/xmodule/tests/test_annotatable_block.py
+++ b/xmodule/tests/test_annotatable_block.py
@@ -43,7 +43,9 @@ def setUp(self):
self.annotatable = self.annotatable_class(
get_test_system(),
DictFieldData({'data': self.sample_xml}),
- ScopeIds(None, None, None, BlockUsageLocator(CourseLocator('org', 'course', 'run'), 'category', 'name'))
+ ScopeIds(
+ None, 'category', None, BlockUsageLocator(CourseLocator('org', 'course', 'run'), 'category', 'name')
+ )
)
def test_annotation_data_attr(self):
diff --git a/xmodule/tests/test_capa_block.py b/xmodule/tests/test_capa_block.py
index c2179e20a4f0..19424f0e2761 100644
--- a/xmodule/tests/test_capa_block.py
+++ b/xmodule/tests/test_capa_block.py
@@ -37,7 +37,7 @@
from xmodule.tests import DATA_DIR
from ..capa_block import RANDOMIZATION, SHOWANSWER
-from . import get_test_system
+from . import get_test_system, make_test_scope_ids
class CapaFactory:
@@ -4046,7 +4046,7 @@ def _user_state(self, username="testuser", response_count=10, suffix=""):
def _get_block(self):
"""Create and return a mock ProblemBlock with default test data."""
- scope_ids = Mock(block_type="problem")
+ scope_ids = make_test_scope_ids('problem')
block = ProblemBlock(get_test_system(), scope_ids=scope_ids)
block.runtime = Mock()
block.data = "