Skip to content

Resolve Opaque Key coherency issues #322

@kdmccormick

Description

@kdmccormick

Development notes

PRs

The OEP:

  1. docs: OEP-68 Learning Content Identifiers openedx-proposals#773

openedx-core PRs:

  1. feat!: Collection.key -> Collection.collection_code #542
  2. feat!: Component.local_key -> Component.component_code #544
  3. feat!: Add Container.container_code field #545
  4. feat!: Package and Entity keys are now opaque refs #546
  5. feat!: ComponentVersionMedia.key -> ComponentVersionMedia.path #547

openedx-platform PR:

Follow-ups

Testing

TBC

AI Usage in PRs

I used Claude Code to help me write all the PRs. I developed a plan for the entire set of 5 changes, and then had it break the plan into 5 parts, one for each commit, before having it implement everything. I've reviewed each changeset by hand and tweaked it, both using Claude and on my own. All commits which Claude was involved in have co-author credit.

Original ticket:

Problems and questions

  • Inconsistent usage of id, pk, uuid, slug, key throughout learning core
  • Confusion between usage keys and our new suite of non-usage-key "keys" (ie, PublishableEntity.key)
  • Lack of standard parsing functions for PublishableEntity.key
  • Wasted time and energy marshaling between UsageKeys and PublishableEntity.keys
  • Should PE keys be usage keys?
  • Should we delete PE UUIDs?

Original issue

Working with Learning Core's authoring api is mostly a joy, except for the inconsistent usage of the terms "id", "key", and "slug". This applies to the LC-related objects and models in opaque-keys and edx-platform, as well.

I would propose standardizing on these meanings of each term for all new content-related code, and for any existing code which is not too burdensome to change:

  • *_id is an integer primary key.
  • *_uuid is a UUID.
  • *_slug is a URL-friendly string which identifies something within a local scope. On the Component model, we currently call this is a "local key".
  • *_key is a string (or an opaque-keys object) which uniquely identifies something across a whole Open edX instance. Can be composed of slugs, or of other slug-like things like a block/component type.

For example, one change I'd like to make is:

  • On the model, Collection.key should be renamed Collection.slug
  • The corresponding field on the opaque-keys object, LibraryCollectionLoctator.collection_id should be renamed LibraryCollectionLocator.slug.
  • Function arguments and dataclass members should be renamed accordingly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions