Uh oh!
There was an error while loading. Please reload this page.
fix: write version=0 in ChannelMetadata for draft publishes - #5853
Conversation
rtibbles
left a comment
There was a problem hiding this comment.
The right behavioural fix - but the test is testing the implementation, not the result.
| self.assertEqual(draft_version.channel_language_id, "fr") | ||
| class MapChannelToKolibriChannelTestCase(StudioTestCase): |
There was a problem hiding this comment.
I think I'd rather we make assertions about the end result of the published database ChannelMetadata version than worry about implementation details in the publish functions.
There was a problem hiding this comment.
Fixed. The tests now call create_content_database directly (mocking only save_export_database to avoid filesystem ops) and query kolibrimodels.ChannelMetadata.objects.get(id=channel.id).version from the returned temp SQLite file — asserting on what actually ended up in the content DB rather than on mock call args.
Propagate is_draft_version from create_content_database into map_channel_to_kolibri_channel so the exported content DB records version=0 for draft publishes instead of channel.version + 1. Kolibri's version-upgrade logic replaces any DB whose version is lower than the incoming version, so version=0 ensures any real publish (version >= 1) will always supersede a draft. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
abf8f3a to
8e58eb2CompareUh oh!
There was an error while loading. Please reload this page.
Summary
map_channel_to_kolibri_channelunconditionally wrotechannel.version + 1into the exported content DB'sChannelMetadata.version, even for draft publishes. Kolibri usesversion=0to mark a draft DB (any real published version > 0 can replace it). Without this fix, a draft DB was indistinguishable from a regular published DB at the same version, breaking Kolibri's upgrade/revert path.Fix: add
is_draft_version=Falsetomap_channel_to_kolibri_channeland propagate the existing flag fromcreate_content_database.References
Closes#5852
Reviewer guidance
Two changes in
publish.py:is_draft_version=Falseparameter onmap_channel_to_kolibri_channel(line 798)version=0 if is_draft_version else channel.version + 1test_publish.py::MapChannelToKolibriChannelTestCasecovers both branches;channel.versionis pre-incremented so the draft value (0) and non-draft value (channel.version + 1) are distinct.No auth, migration, or API changes — low risk.
AI usage
Claude Code (claude-sonnet-4-6) implemented this fix end-to-end following a pre-written plan. I reviewed the diff for correctness and confirmed the tests cover both branches.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?