Skip to content

Select the channel import class from the database's shape - #15220

Open
rtibbles wants to merge 1 commit into
learningequality:developfrom
rtibbles:fix-channel-import-schema-version-selection
Open

Select the channel import class from the database's shape#15220
rtibbles wants to merge 1 commit into
learningequality:developfrom
rtibbles:fix-channel-import-schema-version-selection

Conversation

@rtibbles

Copy link
Copy Markdown
Member

Summary

Our test coverage failed to test on actual Studio shaped databases - where there are extra columns for backwards compatibility, so failed to ensure proper schema detection. Upgrading a channel aborted once Studio began publishing the renamed file size column alongside the legacy one. The import class came from the database's declared minimum schema version — a floor Studio has always published as 1 — while the columns read came from the newer shape the file actually has, so the legacy rename mapped off a column that was never selected. Infer the newest schema version a database fits, and use it for both.

References

Regression from #15174. First seen: QA channel 95a52b38 at version 162.

Reviewer guidance

  1. Import the QA channel at version 162 onto a device already holding an earlier version — it upgrades instead of aborting, and its nodes keep the learning activities Studio published rather than ones derived from their kind.
  • Every Studio-published channel now routes through the current import class rather than the version-1 one, so the learning-activity and included-preset backfills stop running for them. That restores what Studio published, but it changes imports for every channel, not only the ones that failed.
  • Inference answers 3 for a version 2 database, since version 3 dropped two columns and a version 2 file therefore fits it. I took newest-fit over most-columns-matched; nothing that reaches the destination differs, but it is the one place the two rules disagree.

AI usage

Used Claude Code to diagnose the failure from the traceback and implement the fix and its tests; the ratchet-down inference rule was my call, once we had established that min_schema_version never described the shape. Verified with the content test suite, prek, and a manual import of the real channel database that failed.

min_schema_version is a floor, not a description: Studio keeps its published
databases readable by the oldest schema it still supports, and has declared 1
throughout. Picking the import class from it while reading the columns of the
shape the file actually has left one importer mapping at version 1 and reading
at version 6, so the QA channel's v162 publish — which carries file_size_bigint
alongside the legacy file_size the floor promises — mapped file_size_bigint off
a column that was never selected.

Infer the newest schema version a file fits and use it for both. The floor now
only gates whether we can read the file at all, which it has never done: the
KeyError that guarded it cannot come from dict.get.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZbu6D5tudALEEwJidhtM1
@github-actions github-actions Bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@rtibbles
rtibbles marked this pull request as ready for review August 20, 2026 19:57
@marcellamaki
marcellamaki self-requested a review August 20, 2026 20:32
@rtibbles rtibbles added this to the Kolibri 0.20 milestone Aug 21, 2026
@radinamatic

Copy link
Copy Markdown
Member

@rtibblesbot For manual QA I only see something actionable at item 1 of the above Reviewer guidance... Could you clarify if there's anything else needed for manual QA?

@marcellamaki marcellamaki self-assigned this Aug 25, 2026
@radinamatic

Copy link
Copy Markdown
Member

I re-tested the workflow under 1. reviewer guidance, and the underlying issue seems fixed: old version (140-ish) of the QA channel is successfully updated to the newest one, the current on Studio, and all the resources are available in the local Kolibri Library.

Waiting to hear if there are any other workflows that need testing before I approve!

cc @marcellamaki

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

Labels

DEV: backend Python, databases, networking, filesystem... SIZE: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants