Skip to content

Annotatable: newly created empty block in a Content Library V2 fails to render (XMLSyntaxError: Document is empty) #323

Open

Description

@irfanuddinahmad

Summary

A newly created Annotatable component in a Content Library V2 can't be previewed: the preview returns HTTP 500 until content is saved into it.

Found while smoke-testing openedx/openedx-platform#38746 (removal of the built-in Annotatable block) on a local Tutor nightly (platform master + xblocks-core 2.0.0).

Steps to reproduce

  1. In a V2 library, create a new Annotatable component through the REST API (POST /api/libraries/v2/<lib>/blocks/ with {"block_type": "annotatable", ...}). Its OLX is <annotatable />.
  2. Open its preview (GET /api/xblock/v2/xblocks/<usage_key>/view/student_view/).

Actual

xblock_annotatable/block.py:183 get_html
  -> etree.fromstring(self.data)
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1

Correction (2026-11-11): an earlier version of this issue said the authoring MFE's "New → Advanced → Annotation" menu creates such a block. That's wrong: annotatable isn't in the library's allowed block types (GET /api/libraries/v2/<lib>/block_types/), so the library UI doesn't offer it. The empty block is reachable through the REST API (above) and, verified, through course OLX import: a course whose annotatable/<url_name>.xml is a bare <annotatable></annotatable> imports fine but then returns HTTP 500 in the LMS.

Cause

AnnotatableBlock.definition_from_xml maps a bare <annotatable/> to data="" (the empty-data branch added with pointer-tag support in #118). get_html() and _render_content() then call etree.fromstring("").

The built-in block (_BuiltInAnnotatableBlock on platform master) uses RawMixin.definition_from_xml, which always serializes the node, so it stored "<annotatable/>" and rendered an empty annotatable. Platform master already defaults to the extracted block, so the built-in toggle is currently the only working fallback, and #38746 removes it.

Related, not yet verified

With empty data, definition_to_xml returns None ("Could not serialize ..."). An empty Annotatable may therefore be dropped on OLX export, where the built-in exported <annotatable/>.

Fix

Draft PR to follow: parse data through a helper that treats empty data as an empty <annotatable/> element, plus regression tests.

| Generated using Claude Code

Activity

  1. irfanuddinahmad commented on Nov 11, 2026

    @irfanuddinahmad
    ContributorAuthor

    Follow-up, verified on the local Tutor nightly stack:

    • Course OLX import is affected too. A course with a pointer tag <annotatable url_name="x"/> whose definition file annotatable/x.xml is a bare <annotatable></annotatable> imports successfully (status 4). Studio shows data: '', and the LMS render (/xblock/<usage>) returns 500 with the same XMLSyntaxError: Document is empty.
    • With the fix from fix: store bare <annotatable/> as OLX, like the built-in block #324 patched into the LMS container, the same block renders 200. Restoring main gives 500 again.
    • Correction to my original report: the library UI doesn't offer Annotatable (annotatable isn't in /api/libraries/v2/<lib>/block_types/), so in libraries the empty block only arises via the REST API or paste/import. The issue body has been updated.

    | Generated using Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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