Content node tree advertises more children when a filter leaves none

Open
#16,083 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python, sqlite
Domain
api, backend

Research direction

Start in kolibri/core/content/viewsets/contentnode/tree.py around lines 216-230, where children.more is set by comparing rght values only, and check what the filtered child query returns after the page. The public v2 tree endpoint shares this code, so look there too. Done when children.more is null if no further child passes the filters, and still set when a thirteenth child does pass; verify with the tree endpoint tests.

Written by the indexing model from the issue text.

Description

APP: Learn bug DEV: backend

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

Target branch: develop

Observed behavior

  • /api/content/contentnode_tree/<id>/ sets children.more whenever a full page ends before the parent's last descendant, comparing rght values only.
  • When the request's filters exclude every child after that page, the request built from children.more returns 200 with no children key.
  • include_coach_content=false, which Learn sends for learners, does this for a topic whose 12 learner resources are followed by one coach resource. languages=es does it for 12 es children followed by one en child.
  • /api/public/v2/contentnode_tree/<id>/ shares the code.

Expected behavior

children.more is null when no further child passes the request's filters.

User-facing consequences

Learn reads data.children.results from the continuation without checking for children, in loadMoreContents, loadMoreTopics and TopicsContentPage.vue. A learner in such a topic is offered more resources that do not exist.

Steps to reproduce

  1. Create a topic with 13 child resources, the last one with coach_content=True.
  2. GET /api/content/contentnode_tree/<topic id>/?include_coach_content=false.
  3. The response holds 12 children, and children.more.params carries include_coach_content=false, depth=2 and a next__gt.
  4. GET the same URL with those params.
  5. The response is 200 and has no children key.

Context

  • Kolibri develop at 758605b764.
  • SQLite, Django test client.

Acceptance Criteria

  • For the topic in the steps above, the first response's children.more is null.
  • The same holds for a child topic whose page of 12 grandchildren is followed only by filtered-out nodes.
  • A topic with 13 children that all pass the filters still returns children.more, and its continuation returns the thirteenth child.
  • Both hold on the local and the public v2 tree endpoints.
  • A tree request issues no more queries than it does today when no page is full.

AI usage

Written by rtibblesbot, an LLM-based coding agent (Claude Code), which found this while reviewing the branch for #15043 and reproduced the responses above with Django's test client.

Dominant language
Python
Stars
1.2k
Forks
1.1k
Avg merge
2d 9h
Merged PRs (30d)
87

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from learningequality/kolibri

All issues in learningequality/kolibri

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.