Unprovisioned device serves plugin pages when the URL's language is not the active one

Open
#16,047 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
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python

Research direction

Read ProvisioningErrorHandler in kolibri/core/device/middleware.py and its middleware ordering in kolibri/deployment/default/settings/base.py. Run the reproduction test from the issue in kolibri/core/test/test_setup_redirect_language.py, then check the listed language and API requests. Done means unprovisioned plugin pages redirect to the matching language's setup wizard, while setup and API requests retain the specified behavior.

Written by the indexing model from the issue text.

Description

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

On an unprovisioned device, a plugin page URL is served instead of redirected to the setup wizard when its language prefix differs from the language active on the thread handling the request.

Active language Request Response
en GET /en/learn/ 302 to /en/setup/
en GET /fr-fr/learn/ the Learn view renders
fr-fr GET /en/learn/ the Learn view renders
fr-fr GET /en/facility/ the Facility view renders

ProvisioningErrorHandler resolves request.path_info and passes the request through on Resolver404. It runs before KolibriLocaleMiddleware, so i18n_patterns still matches only the prefix of the language the previous request on that thread left active.

Expected behavior

Every plugin page URL redirects to the setup wizard until the device is provisioned.

Steps to reproduce

Save this test as kolibri/core/test/test_setup_redirect_language.py and run it with pytest:

from django.test import Client
from django.test import TestCase
from django.utils import translation


class SetupRedirectLanguageTest(TestCase):
    databases = "__all__"

    def test_redirects_url_in_inactive_language(self):
        translation.activate("en")
        response = Client(raise_request_exception=False).get("/fr-fr/learn/")
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response["Location"], "/fr-fr/setup/")

It fails with AssertionError: 500 != 302 in a checkout without built frontend bundles: the Learn view runs and raises WebpackError.

Context

  • Kolibri develop at 886a0c9f24, no URL_PATH_PREFIX
  • Python 3.10, Django test client
  • #14067 (closed, fixed by #14200) added this redirect; its fix missed URLs in a language other than the active one.

Acceptance Criteria

  • On an unprovisioned device with en active, GET /fr-fr/learn/ returns 302 to /fr-fr/setup/.
  • On an unprovisioned device with fr-fr active, GET /en/learn/ and GET /en/facility/ return 302 to /en/setup/.
  • With en active, GET /fr-fr/setup/ is still served by the setup wizard.
  • A request to an API endpoint still runs no provisioning check.

AI usage

Claude Code found this while working on #15794, reproduced it on develop with the test above and the requests in the table, and wrote this text.

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.