Skip to content

Draft publish writes non-zero version to exported content database ChannelMetadata #5852

Description

@rtibbles

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: unstable

Observed behavior

When a channel is draft-published, the exported content database records a positive integer in ChannelMetadata.version instead of 0.

map_channel_to_kolibri_channel (contentcuration/contentcuration/utils/publish.py:802-813) unconditionally writes:

version=channel.version + 1,  # Need to save as version being published, not current version

The function receives use_staging_tree but not is_draft_version, so the draft case is not distinguished. The caller create_content_database (same file, lines 143-202) already knows is_draft_version and switches the file-save path to "next", but the in-DB ChannelMetadata.version still gets channel.version + 1.

Expected behavior

On a draft publish, the exported content database's ChannelMetadata.version should be set to 0. This follows the Kolibri convention where version=0 marks a draft content DB as upgradeable to a non-draft version.

Non-draft publishes continue to write channel.version + 1 unchanged.

User-facing consequences

  • There is no explicit "draft" workflow in Kolibri today; draft handling relies on Kolibri's existing version-upgrade behavior (importing a higher-numbered version clears the draft and reverts the channel to a regular content DB).
  • If Studio writes a draft content DB with version = channel.version + 1, Kolibri cannot tell it apart from a regular published DB at the same version number. A draft could get picked up and treated as the latest version, blocking the intended upgrade/revert path.
  • Writing version = 0 in the content DB encodes draft-ness in the artifact itself, so Kolibri's upgrade logic naturally replaces a draft with any real published version (since any real version > 0), independent of whatever higher-level draft handling Kolibri may or may not add later.

Steps to reproduce

  1. On Studio unstable at d9dbadb86 (or later), open a channel and trigger a draft publish.
  2. Retrieve the exported draft content database (e.g. via the "next" path used by save_export_database with is_draft_version=True).
  3. Inspect the DB's ChannelMetadata row:
    SELECT id, name, version FROM content_channelmetadata;
  4. Observe: version is channel.version + 1 (a positive integer), not 0.

Context

AI usage

Drafted with Claude (Opus 4.7) via Claude Code — Claude traced the publish path and drafted each section; I reviewed section-by-section and corrected the user-facing consequences to reflect that Kolibri has no explicit draft workflow and version=0 is a safeguard, not a required marker for an existing UX.

Acceptance Criteria

  • On a draft publish, the exported content database's ChannelMetadata.version is 0.
  • On a non-draft publish, ChannelMetadata.version continues to equal channel.version + 1 (no regression).
  • is_draft_version is propagated from create_content_database to map_channel_to_kolibri_channel (or equivalent) so the version assignment has access to the draft flag.
  • Tests cover: (a) draft publish produces a content DB with ChannelMetadata.version == 0, (b) non-draft publish produces a content DB with ChannelMetadata.version == channel.version + 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions