Repository navigation
Normalise node id in public contentnode tree endpoint - #6464
ManyaJain111 wants to merge 1 commit into
Conversation
|
👋 Hi @ManyaJain111, thanks for contributing! For the review process to begin, please verify that the following is satisfied:
📢✨ Before we assign a reviewer:
Also check that issue requirements are satisfied & you ran Pull requests that don't follow the guidelines will be closed. Reviewer assignment can take up to 2 weeks. |
🟡 Waiting for changesOutcome: reviewed Last updated: 2026-11-21 20:50 UTC |
rtibblesbot
left a comment
There was a problem hiding this comment.
PR #6464 fixes the uppercase node id bug at its root. The id is normalised where it is parsed. The parent comparison and tree queries now see one canonical form. The regression test pins the full response against the lowercase request. CI is passing.
Next step: Needs a full code review by a human engineer.
- The author is outside the team.
Written by rtibblesbot, an LLM-based coding agent.
|
|
||
| try: | ||
| UUID(pk) | ||
| pk = UUID(pk).hex |
There was a problem hiding this comment.
praise: UUID(pk).hex matches the serializer's parent form. The parent check and tree queries now share one canonical id.
Summary
The public contentnode tree endpoint now returns the same response for a node id in uppercase as in lowercase. Before this change, an uppercase id returned the parent node with no
children.ContentNodeTreeViewset.retrievevalidatedpkwithUUID(pk)but it discarded the result and it kept usingpkexactly as sent. The database lookups would still findd the node, because Postgres compares UUIDs as values and ignores case. But when building the nested response, children are attached to the parent by a plain string comparison:desc["parent"]is serialized as lowercase hex, so for an uppercasepkthis never matched, and every child was silently dropped.Approach: keep the parsed value instead of discarding it:
.hexalways gives 32 lowercase characters with no dashes, the same form the serializedparentvalues use. Everything after validation, including the queries and the comparison, now works with one canonical id. This is the normalisation the issue asks for, and it's a one-line change at the point where the id is already being parsed. Invalid ids still return 400 as before.References
Fixes #6417
Reviewer guidance
Automated tests: I added
test_contentnode_tree_uppercase_idtocontentcuration/kolibri_public/tests/test_content_app.py. It requests the same node with its id in lowercase and in uppercase, and checks that the uppercase request returns 200, includeschildren, and matches the lowercase response. It fails without the fix ('children' not found) and passes with it. All tests in the file pass, and no existing tests were changed.Manual verification: on the dev server, using the id of a topic node that has children:
GET /api/public/v2/contentnode_tree/<id>/returned the node withchildrenGET /api/public/v2/contentnode_tree/<ID IN UPPERCASE>/returned the same response, also withchildren(before the fix,childrenwas missing)Note for reviewers: because the fix uses
UUID(pk).hex, ids sent in dashed form (xxxxxxxx-xxxx-…) are normalised too. They had the same mismatch before.No UI changes.
AI usage
I used Claude Code to first write a regression test that reproduced the missing
childrenissue. I then guided it to trace the failure to the exact location in the code, investigated the root cause, and worked with it to implement a targeted fix. Finally, I reviewed the changes and independently re-ran the tests to verify that the issue was resolved.I reviewed the changes and tests line by line, made sure I understood why
pkneeded to be normalised before the string comparison, and independently re-ran the tests on a branch based onhotfixes.