Skip to content

fix: allow restoring content with blank titles#610

Draft
kdmccormick wants to merge 1 commit into
openedx:mainfrom
kdmccormick:kdmccormick/blank-unit-title
Draft

fix: allow restoring content with blank titles#610
kdmccormick wants to merge 1 commit into
openedx:mainfrom
kdmccormick:kdmccormick/blank-unit-title

Conversation

@kdmccormick

@kdmccormick kdmccormick commented Jun 22, 2026

Copy link
Copy Markdown
Member

Description

Restoring a library archive failed whenever any unit (or other container/component) version had a blank title. Blank titles are legal (PublishableEntityVersion.title is blank=True) and common — content imported from courses via the modulestore migrator frequently has untitled units, and such content can be backed up.

The version title round-trips as an empty string, but EntityVersionSerializer.title used CharField(required=True), which defaults to allow_blank=False, so the empty string failed validation and aborted the whole restore. This sets allow_blank=True so blank titles validate.

The library_backup test fixture's unit1 now has a blank title to exercise this path, with a regression test asserting it restores correctly.

Related issue

Fixes openedx/openedx-platform#38611

Manual testing instructions

This is the updated library from the test suite:

fixture-library.zip

Restore it on master gives:

Errors encountered during restore:
entities/unit1-b7eafb.toml: {'title': [ErrorDetail(string='This field may not be blank.', code='blank')]}
entities/unit1-b7eafb.toml: {'title': [ErrorDetail(string='This field may not be blank.', code='blank')]}

Restoring it on this PR's sandbox works (TODO need to verify this once the sandbox is up!)

Other notes

  • This relaxes allow_blank only on entity version titles (units, sections, subsections, components). Learning package and collection titles are unchanged.

AI

Generated by Claude Opus 4.8 with this prompt:

issue: Library Restore fails when Unit titles are blank. it is
both legal and common for people to have untitled content in
courses. The modulestore migrator can bring this content in from
courses, and we can export it as a backup archive. Restoring that
same data should also work.
context: A "library" is is a bundle of reusable learning content.
You will not actually see the term "library" in this repo, but you
will see "LearningPackage", which at this time is 1:1 with
Library. The src/openedx_content/applets/backup_restore applet is
resonsible for serializing learning packages to and from ZIP
archives. The aforementioned "moduelstore migrator" is not
something you need to worry about--it's a subsystem of
openedx-platform (the django project which uses this library,
openedx-core) which transfers content in from our legacy storage
format into openedx-core-based learning packges, and (as
mentioned) it supports blank unit titles.
instructions:

  • Start in just src/openedx_content. I expect the bug to be in the
    backup_restore applet. it's ok to read src/openedx_django_lib if
    necessary too, but if you find youself needing to read other
    openedx-core code, or other openedx libraries, or the
    openedx-platform (which is where Libraries are defined) then pause
    and talk to me first.
  • .imporlinter will explain the code structure to you and help you
    avoid unnecessary code walking and test-running
  • when running python, use the venv at .venv/bin/activate
  • you can validate changes by running:
    • pycodestyle src # basic quality checks, fast
    • pylint src/ # slow quality checks; use targeted paths
    • pytest src/ # unit tests; use targeted paths
    • lint-imports # structural checking
  • use builtin tools whenever possible

I reviewed the code and had it rework the test to be simpler.

Merge deadline

ASAP. We will want to backport this to Verawood before the release, which is probably next week.

Restoring a library archive failed whenever any unit (or other
container/component) version had a blank title. Blank titles are legal
(PublishableEntityVersion.title is blank=True) and common -- content
imported from courses via the modulestore migrator frequently has
untitled units, and such content can be backed up.

The version title round-trips as an empty string, but
EntityVersionSerializer.title used CharField(required=True), which
defaults to allow_blank=False, so the empty string failed validation and
aborted the whole restore. Set allow_blank=True so blank titles validate.

The library_backup fixture's unit1 now has a blank title to exercise this
path, with a regression test asserting it restores correctly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kdmccormick kdmccormick added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-sandbox open-craft-grove should create a sandbox environment from this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Library Restore fails when Unit titles are blank

2 participants