feat!: Package and Entity keys are now opaque refs#546
Merged
kdmccormick merged 3 commits intomainfrom Apr 21, 2026
Merged
Conversation
This was referenced Apr 15, 2026
845c3c7 to
fbe4b4b
Compare
1fcd411 to
aba969c
Compare
0f70804 to
266d7f3
Compare
0b01361 to
52fe205
Compare
ormsbee
reviewed
Apr 15, 2026
266d7f3 to
5283857
Compare
52fe205 to
b9d11db
Compare
c32f78c to
94bd0e5
Compare
09bbd04 to
3f23389
Compare
8434cbf to
64f0eeb
Compare
29580c7 to
3a446d5
Compare
fd76848 to
28197b9
Compare
64f0eeb to
f67afa4
Compare
28197b9 to
9d0ed28
Compare
kdmccormick
commented
Apr 17, 2026
f67afa4 to
ed3aadc
Compare
9d0ed28 to
f5e419d
Compare
Member
Author
|
This is almost ready, but I'm still wrestling with translation between the backup-restore terms (keys) and the model terms (refs). EDIT: It's all ready now. |
The `{LearningPackage,PublishableEntity}.key` fields were always meant to be
externally-supplied refs whose format does not matter. However, they were
effectively being used as parseable psuedo-keys for identifying containers and
components, with more assumptions to their structure being baked in over time,
both within and outside openedx-core.
This commit renames them to `{package,entity}_ref`, and removes all parsing of
them from the API and from the internals (except for where required for
backcompat with Ulmo ZIP backups). Instead, the pairings of
(component_type,component_code) and (container_type,container_code) are used to
identify components and containers; their respective entity_refs are derived
from those *by convention* but the publishing app has no conception of this
convention.
BREAKING CHANGES to **openedx_django_lib**:
* Renamed key_field(...) -> ref_field(...) in openedx_django_lib.
BREAKING CHANGES to **models** API:
* Renamed field LearningPackage.key -> LearningPackage.package_ref.
* Renamed field PublishableEntity.key -> PublishableEntityKey.entity_ref
* Renamed field PublishableEntityMixin.key -> PublishableEntityMixin.entity_ref
* Renamed property PublishableEntityVersion.key -> PublishableEntityVersion.entity_ref
BREAKING CHANGES to **publishing** API:
* In create_learning_package(...), renamed param key -> package_ref
* In update_learning_package(...), renamed param key -> package_ref
* In learning_package_exists(...), renamed param key -> package_ref
* In create_publishable_entity(...), renamed param key -> entity_ref
* Renamed get_publishable_entity_by_key(...) -> get_publishable_entity_by_ref(...),
and renamed param key -> entity_ref
* Renamed get_learning_package_by_key(...) -> get_learning_package_by_ref(...),
and renamed param key -> package_ref
BREAKING CHANGES to **components** APIs:
* Removed function get_or_create_component_type_by_entity_key()
BREAKING CHANGES to **container** APIs:
* Renamed get_container_by_key(...) -> get_container_by_code(...),
and renamed param key -> container_code
* Rename get_container_children_entities_keys(...) -> get_container_children_entity_refs(...)
* Renamed get_container_children_entities_keys(...) -> get_container_children_entity_refs(...)
BREAKING CHANGES to **collections** API:
* In get_entity_collections(...), renamed param entity_key -> entity_ref
BREAKING CHANGES to **media** API:
* In look_up_component_version_media(...):
* Renamed param learning_package_key -> learning_package_ref
* Renamed param component_key -> entity_ref
* In add_assets_to_component management command:
* Renamed argument learning_package_key -> learning_package_ref
* Renamed argument component_key -> entity_ref
BREAKING CHANGES to **backup_restore** API:
* In load_learning_package(...):
* Renamed param key -> package_ref
* In return dict, within sub-dict ["lp_restored_data"]:
* Renamed ["key"] -> ["package_ref"]
* Renamed ["archive_lp_key"] -> ["archive_package_ref"]
* Renamed ["archive_org_key"] -> ["archive_org_code"]
* Renamed ["archive_slug"] -> ["archive_package_code"]
* If archive_package_ref cannot be parsed into
"{_prefix}:{org_code}:{package_code}", then archvie_org_code and
archive_package_code will both be None. Callers should handle this case.
(Previously, a ValueError would be raised by backup-restore code.)
Backup-restore still write and reads entity_ref and package_ref to/from TOML files as `key`
for backwards compatibility. This may change in a future "v2" restore format.
Part of: #322
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1a51119 to
02c300d
Compare
bradenmacdonald
approved these changes
Apr 21, 2026
Contributor
bradenmacdonald
left a comment
There was a problem hiding this comment.
I read through the code and it looks great. Some very minor suggestions.
I did not test anything, but can do so when the platform PR is ready if you'd like.
Co-authored-by: Braden MacDonald <braden@opencraft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
{LearningPackage,PublishableEntity}.keyfields were always meant to be externally-supplied refs whose format does not matter. However, they were effectively being used as parseable psuedo-keys for identifying containers and components, with more assumptions to their structure being baked in over time, both within and outside openedx-core.This commit renames them to
{package,entity}_ref, and removes all parsing of them from the API and from the internals (except for where required for backcompat with Ulmo ZIP backups). Instead, the pairings of (component_type,component_code) and (container_type,container_code) are used to identify components and containers; their respective entity_refs are derived from those by convention but the publishing app has no conception of this convention.BREAKING CHANGES to openedx_django_lib:
BREAKING CHANGES to models API:
BREAKING CHANGES to publishing API:
BREAKING CHANGES to components APIs:
BREAKING CHANGES to container APIs:
BREAKING CHANGES to collections API:
BREAKING CHANGES to media API:
BREAKING CHANGES to backup_restore API:
Backup-restore still write and reads entity_ref and package_ref to/from TOML files as
keyfor backwards compatibility. This may change in a future "v2" restore format.
Part of: #322
Full series of PRs:
keysare now opaquerefs#546Testing, AI Usage, and Merge Considerations
See #322