H5P and Bloom request a peer's zipcontent files from the local server
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Target branch: release-v0.20.x
Observed behavior
H5PRunner.js:141-145andBloomRunner.js:108-112buildzipcontentUrlfrom the last/segment of the storage URL.- A peer's storage URL carries the peer as
?baseurl=<peer>, so the zipcontent URL drops the peer and points at the local server. - H5P also builds its content path, library fallback and
urlLibrariesfromzipcontentUrl(L241, L297, L419), so those requests go to the local server too. - #15820 fixes the Bloom side on develop only.
- Reported by rtibbles in a review of #15820.
Steps to reproduce
- Browse a peer's library that has an H5P resource containing a file over the large-file threshold (e.g. a video).
- Open the resource and watch the network tab: the large file is requested from the local
zipcontent/<file>.h5p/....
Acceptance Criteria
- [ ] For a storage URL with
?baseurl=<peer>, H5P and Bloom request every zipcontent file fromzipcontent/<encoded peer>/<file>/<path>. - [ ] Local storage URLs keep requesting
zipcontent/<file>/<path>. - [ ] H5PRunner and BloomRunner build the URL with one shared helper.
- [ ] Jest tests in the H5P and Bloom viewers cover both cases.
AI usage
Claude Code drafted this from rtibbles's review finding on #15820 and read the H5P and Bloom runner code to confirm the URL construction. I widened it to Bloom and to every zipcontentUrl use for 0.20.
Widened for 0.20: BloomRunner.js on release-v0.20.x has the same bug (#15820 fixes it on develop only), and H5P's other zipcontentUrl uses also miss the peer. Both runners should share one URL helper.
Checked the body against release-v0.20.x: the Bloom and H5P line refs (H5P L141/241/297/419, Bloom L108) match, and the shared-helper acceptance criterion covers both runners. No edits needed.
Plan: H5PRunner and BloomRunner build their zipcontent URL with one helper that keeps a storage URL's ?baseurl=<peer> as zipcontent/<encoded peer>/<file>.
- [ ] Shared helper, adopted by BloomRunner
- [ ] H5PRunner adopts the helper
- [ ] Self-review the produced code
Assumptions — the issue did not settle these; say so if one is wrong.
- Helper lives in
kolibri-sandboxaskolibri-sandbox/zipcontent; if wanted inkolibri-zip, the file and two imports move, behaviour unchanged. - This PR leaves #15820 alone; if it should adopt the helper before this forward-merges, develop's
BloomRunner.jsneeds that edit there. - The real
kolibri-zipoverxhr-mockdrivesH5PRunner.initthrough toshimH5Pin jsdom — not run, the planning worktree has nonode_modules; Bloom's equivalent is proven by develop's spec. If it can't be made to pass, H5P's spec keepsjest.mock('kolibri-zip')and reads the large-file generator fromZipFile.mock.lastCall, and the PR body names that seam. xhr-mockmatches a storage URL carrying an unencoded?baseurl=http://…/— #15820's spec only exercises the encoded form. If it doesn't, register the handler with a regex; the string passed toinitstays unencoded, as the server emits it.
Written by rtibblesbot, an LLM-based coding agent.
Decided without asking; a reply here changes it.
- Video: this PR leaves the 0.20 Bloom Player's URL rewrite alone, and a follow-up issue is drafted for it. The player prefixes every
srcthat is notblob:with the book's blob URL, so a video of 500 KB or more never loads, for local books as well as a peer's, and in v0.19.4 and v0.19.5 too. "An acceptance criterion is not met without it" pointed to fixing here; "the work is in another repository" outweighed it, becausestatic/bloom/is built fromlearningequality/bloom-player'spatchedbranch, which I cannot push to, and this branch did not cause the defect. Until the follow-up lands, Bloom's half of the first criterion holds for the URL BloomRunner writes into the book, which the spec asserts, and not in the browser; H5P's half holds in the browser. - Audio: same decision, same follow-up issue. BloomRunner writes narration and background audio as
_<last URL segment>and the player rebuilds that as a blob URL, so audio of 500 KB or more is silent, local or peer. The same two lines applied with the same weighing; develop already carries both fixes as patches 0003 and 0006 of its in-tree player build.
Written by rtibblesbot, an LLM-based coding agent.
Decided without asking; a reply here changes it.
- Peer addresses with a path prefix and no trailing slash (
http://peer:8080/kolibri): left alone, with no follow-up issue. Nothing Kolibri stores has that shape:NetworkClient.connect()rewrites every saved peer address to end in/(…/kolibri/api/public/info/→…/kolibri/), zeroconf builds it from aURL_PATH_PREFIXthat the options validator ends in/, and the learn pages senddevice.base_urlunchanged, so only a hand-typed request carries one. "An edge case with no known affected user" outweighed "same defect at a sibling site": the join that drops the prefix isurljoininkolibri_whitenoise.py:473andjoin_url, which this branch does not touch and which fails the archive's own/content/storage/fetch on release-v0.20.x before either runner builds a URL. For such an address every peer file stays broken, as it is today; the helper passes the peer through as given, and…/kolibri/requestszipcontent/http%3A%2F%2Fpeer.example%3A8080%2Fkolibri%2F/<file>/<path>.
Written by rtibblesbot, an LLM-based coding agent.
Decided without asking; a reply here changes it.
- Debian kolibri-server: this PR leaves its nginx/uWSGI path handling alone, and a follow-up issue is drafted for it. nginx's
uwsgi_paramssetsPATH_INFOto the decoded, slash-merged$document_uri, sozipcontent/http%3A%2F%2Fpeer.example%3A8080%2F/<file>/<path>reaches Kolibri aszipcontent/http:/peer.example:8080/<file>/<path>, whichpath_regexinzip_wsgi.pydoes not match: 404. That is already true on release-v0.20.x for everyzipContentUrlcaller (HTML5, safe HTML5, Perseus, QTI, custom channels) and has been since 48c731b5a1 (June 2023); no open issue or PR covers it. "The issue not naming a host is not a reason to defer" and "fix whatever puts the change where users meet it" pointed to fixing here; "a new mechanism in another subsystem, which this branch neither broke nor needs" outweighed them. The fix changes how the zip content server reads its path, or the nginx config kolibri-server generates, for every archive renderer, and nginx and uWSGI do not run in the agent's sandbox to check it. This branch causes no regression there: on kolibri-server a peer's large H5P and Bloom files return 404 before and after it, and on Kolibri's built-in server, which keeps%2Fencoded, they now load. The PR body will say kolibri-server is not covered.
Written by rtibblesbot, an LLM-based coding agent.
Decided without asking; a reply here changes it.
- Self-review: another round runs instead of pushing, because the blocking finding is true. With the wait for the H5P frame's
loadevent deleted fromH5PRunner.js(L173-175), the uncommittedH5PRunner.spec.jspasses 13 of 13 and the committed one failsstarts H5P once, however many times the host page loads, so the uncommitted edit deletes the only test of that wait. "A blocking finding remains" and "work already written on the branch, related and small: keep it" pointed to another round; "a test nobody asked for is never a reason to fix here" pointed to pushing, since release-v0.20.x's spec also passes with the wait deleted and this PR does not change the wait. The first two outweighed it: the guard is already committed on this branch, and restoring it is one test. Direction for the round, in that test only:- Leave
H5Poff the host page and dropstartWithFrameLoad. - Give the iframe a
contentDocumentgetter that returns{ readyState: 'loading', URL: 'about:blank' }and schedules oneloadwithsetTimeout. - Before
start(), register aonceloadlistener that setshostPage.H5P. - After
await start(), dispatch a secondloadand expect oneH5P.initcall. - This needs no
addEventListenerspy; run in the sandbox, it passes on the real runner (13 of 13) and fails with the wait deleted. - Rename
SIMPLE_PEER_URLtoPEER_URL, and keep the uncommitted path-prefix case inBloomRunner.spec.js.
- Leave
Written by rtibblesbot, an LLM-based coding agent.
Decided without asking; a reply here changes it.
- Peer addresses whose path prefix holds a percent escape (
http://peer.example:8080/my%20school/): left alone, with no follow-up issue and no change to how the zip content server reads its path. Such a peer already fails one step earlier, on release-v0.20.x and on this branch: the storage URL the server emits carries the peer raw (contentnode/base.py:283), the storage route reads it asmy school/, which is not a known peer, and the archive itself returns 404 before either runner builds a URL. Run in the sandbox against a peer stored as…/my%20school/: storage lookup fails for the emitted URL; the zipcontent 404 is reached only with a hand-encoded?baseurl=, which no Kolibri code emits. Plain and/kolibri/-prefixed peers return 200 on both routes. "An acceptance criterion is not met without it" and "the issue not naming a host is not a reason to defer" pointed to fixing here; "an edge case with no known affected user", "a new mechanism in another subsystem, which this branch neither broke nor needs" and the earlier decision on slash-less prefixes outweighed them: keeping the escape through Cheroot's decoding andunquoteinzip_wsgi.py:334changes the route for HTML5, Perseus and QTI too, which build the same segment (packages/kolibri/urls.js:200-203), and would still not make such a peer load. For these peers every file stays broken, as it is today. The self-review finding resolvesdeclined, citing the plan's "Inherited from the zipcontent route"; the PR's review notes already list it as accepted.
Written by rtibblesbot, an LLM-based coding agent.
Fixed in #16042