Skip to content

feat: add library field to v1 and v2 public channel APIs, gate v1 ChannelVersion lookup#5828

Merged
rtibbles merged 4 commits intolearningequality:unstablefrom
rtibblesbot:issue-5821-fac365
Apr 13, 2026
Merged

feat: add library field to v1 and v2 public channel APIs, gate v1 ChannelVersion lookup#5828
rtibbles merged 4 commits intolearningequality:unstablefrom
rtibblesbot:issue-5821-fac365

Conversation

@rtibblesbot
Copy link
Copy Markdown
Contributor

@rtibblesbot rtibblesbot commented Apr 13, 2026

Plan: Add a library enum field ("KOLIBRI", "COMMUNITY", or null) to the v1 and v2 public channel API endpoints, and gate v1 ChannelVersion token resolution behind a channel_versions=true query parameter.

  • Bump le-utils to 0.2.17
  • Write the failing gate test
  • Implement the gate in _get_channel_list_v1
  • Update the three existing channel-version tests
  • Write failing tests for V1 library field
  • Implement library in _serialize_channel_version()
  • Add library field to PublicChannelSerializer
  • Write failing tests for V2 library field
  • Implement library in V2 consolidate()

status

Summary

Adds a library field to the v1 and v2 public channel API endpoints, enabling Kolibri to distinguish Kolibri Library, Community Library, and other channels. Also gates v1 ChannelVersion token resolution behind ?channel_versions=true to prevent older Kolibri clients from accidentally retrieving data they cannot parse.

References

Reviewer guidance

Risky areas worth careful review:

  1. views_v1.py gate?channel_versions=true is a deliberate breaking change to the v1 API contract. Three existing channel-version tests were updated to include the parameter; without it, channel-version token lookups now return 404.
  2. _get_channel_version_library() status filter — must include both STATUS_APPROVED and STATUS_LIVE; any other status (including STATUS_PENDING) correctly returns null.
  3. V2 consolidate() mapping — non-public channels map to "COMMUNITY" (not null), which differs from v1 behaviour where only channel-version tokens with a qualifying submission return "COMMUNITY".

To test: pytest contentcuration/kolibri_public/tests/ -v

AI usage

Implemented using Claude Code following a pre-approved TDD plan (red-green-refactor). Tests were written before each implementation step; the full test suite passed before each commit.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rtibblesbot rtibblesbot marked this pull request as ready for review April 13, 2026 21:05
Copy link
Copy Markdown
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented to spec, but just one area missing testing coverage.

self.assertNotEqual(result["name"], self.channel.name)
self.assertNotEqual(result["description"], self.channel.description)

def test_channel_version_token_lookup_requires_channel_versions_param(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really expected to see a test confirming that without the channel_versions query parameter, the ChannelVersion token would not produce any result. Please add.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test_channel_version_token_without_param_returns_404 — a focused standalone test that uses a channel-version token without ?channel_versions=true and asserts a 404 response. Kept it separate from the combined gate test so the negative case is unambiguously visible on its own.

rtibblesbot and others added 3 commits April 13, 2026 15:07
…=true param and add library field to v1 API responses

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are good - test coverage gives confidence.

@rtibbles rtibbles merged commit e5631c8 into learningequality:unstable Apr 13, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add library enum field to v1 and v2 public channel API responses

2 participants