kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Content node tree advertises more children when a filter leaves none

Open rtibblesbot opened this issue 1 week ago • 0 comments

❌ 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.

rtibblesbot avatar Nov 27 '26 19:11 rtibblesbot