Unprovisioned device serves plugin pages when the URL's language is not the active one
❌ 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
developat886a0c9f24, noURL_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
enactive,GET /fr-fr/learn/returns 302 to/fr-fr/setup/. - [ ] On an unprovisioned device with
fr-fractive,GET /en/learn/andGET /en/facility/return 302 to/en/setup/. - [ ] With
enactive,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.