Skip to content

Conversation

@remo-lab
Copy link
Contributor

Fixes #14067

Problem

When a Kolibri device is not provisioned, only the root URL (/) redirects to the setup wizard.
Direct navigation to user-facing routes such as:

  • /en/learn/
  • /en/learn/#/library
  • /en/facility/

loads the UI instead and shows messages like “No resources available”, which is confusing and bypasses the required device setup flow.

This allows users to reach parts of the application in an invalid, unprovisioned state.


Root Cause

The provisioning check was implemented only in RootURLRedirectView.
Other views (such as LearnView) render their templates unconditionally.

The existing ProvisioningErrorHandler middleware only handles DeviceNotProvisioned exceptions and does not proactively block requests. Since these views never raise that exception, the middleware was never triggered.


Fix

This change moves provisioning enforcement to the middleware layer so it applies consistently to all requests.

  • ProvisioningErrorHandler now checks provisioning status on every request
  • If the device is not provisioned, requests are redirected to the setup wizard
  • Required paths (setup wizard itself, static assets, APIs needed during setup, content downloads, etc.) are explicitly exempted to avoid redirect loops or breakage
  • Existing exception-based handling is preserved as a fallback

This ensures that no user-facing UI is rendered until the device is properly provisioned.

Recording.2026-01-15.232233.mp4

Tests

Added middleware-level regression tests to verify that:

  • Unprovisioned devices are redirected when accessing Learn and related routes
  • The setup wizard and required assets remain accessible during provisioning
  • Provisioned devices continue to behave normally

These tests fail on the previous behavior and pass with this change, helping prevent regressions.


Impact

  • Prevents access to Learn/Facility routes before device setup
  • Fixes confusing empty UI states on fresh installs
  • Enforces a single, consistent provisioning gate for current and future plugins

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Jan 15, 2026
@learning-equality-bot
Copy link

👋 Thanks for contributing!

We will assign a reviewer within the next two weeks. In the meantime, please ensure that:

  • You ran pre-commit locally
  • All issue requirements are satisfied
  • The contribution is aligned with our Contributing guidelines. Pay extra attention to Using generative AI. Pull requests that don't follow the guidelines will be closed.

We'll be in touch! 😊

@remo-lab remo-lab force-pushed the fix/provisioning-redirect-middleware branch from 6f2ce65 to f8010c4 Compare January 15, 2026 20:09
@remo-lab
Copy link
Contributor Author

remo-lab commented Jan 16, 2026

Hi @rtibbles @AlexVelezLl @nucleogenesis ,
This PR makes sure unprovisioned devices are always redirected to the setup wizard, instead of landing on pages like the Learn UI in a half-set state. I’ve also added tests to cover the main cases and avoid regressions.
Whenever you have a moment, I’d really appreciate a review. Thanks!

@nucleogenesis nucleogenesis self-assigned this Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DEV: backend Python, databases, networking, filesystem... SIZE: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Urls not being redirected when device is not provisioned

2 participants