Learner accounts get 403 on /api/courses — and the UI masks it as an empty state
Environment
- DeepTutor v1.6.4 (ghcr.io/hkuds/deeptutor:latest, 2026-09-02)
- Docker deployment, multi-user auth enabled
Summary
Accounts with preset="learner" cannot use the Courses feature at all, and the web UI hides the failure behind a misleading empty state ("创建第一门课程 / create your first course").
Root cause
- When an account is set to
preset=learner, a default learning policy applies:allowed_surfaces: ["chat", "reading"]. _learning_surface_for_path()indeeptutor/api/routers/auth.pyonly maps these roots:/api/reading,/api/chat,/api/question,/api/question-notebook,/api/sessions,/api/knowledge-bases,/api/mastery-paths./api/coursesis not mapped, so the surface resolves to"", andassert_learning_surface("")indeeptutor/multi_user/learning_access.pydenies it → 403.- The frontend
/coursespage swallows the 403 and renders the zero-courses empty state, so admins/guardians can't tell the difference between "no courses yet" and "not permitted".
Reproduction
- Admin creates a learner account (preset=learner).
- Admin creates courses under that account (they persist fine in
data/users/<uid>/user/workspace/courses/courses.json). - Log in as the learner →
/coursesshows the empty state;GET /api/coursesreturns 403.
Suggestion
- Either make Courses a learner surface (map
/api/courses→ e.g."courses"and letallowed_surfacesinclude it by policy), or - If Courses are intentionally non-learner, show an explicit "not available for this account type" message instead of the empty state.
The current behavior makes the guardian/learner preset incompatible with the course system without any signal as to why.
Same pattern confirmed on the Partners surface: with a learner account, GET /api/partners returns 403 (This learning account cannot use the requested server surface), and the /partners page renders the misleading empty state "还没有伙伴 / 创建第一个伙伴" — even though the account actually owns a partner that is live on a Feishu channel. The nav item is not hidden either. So guardians/admins looking at the learner's account may think data was lost. Suggest: for denied surfaces, either hide the nav entry or show an explicit 'not available for this account type' notice; the empty-state-mask pattern appears wherever a surface is denied.
Thanks for the report — the symptom you hit is fixed on dev (#1231): /api/courses now maps to the reading learning surface, and the courses shelf surfaces the server's denial instead of rendering an empty state.
Keeping this open, because the underlying gap is wider than /api/courses. Enumerating every route behind require_learning_surface, roughly 30 prefixes currently deny learner accounts by default — including /api/capabilities, /api/settings, /api/system, /files/attachments, /api/mastery-paths and /api/memory. Whether that whitelist should keep growing one entry at a time or be replaced by an explicit learner-surface list is a policy decision for the maintainers, not something to patch per report.
One small correction: /api/knowledge-bases and /api/mastery-paths were listed as existing roots in the whitelist — they were not there.
@pancacake On the two mappings you confirmed missing — they're implemented in PR #1323: /api/mastery-paths → chat (all methods; progress records are the learner's own per-user data) and /api/knowledge-bases → reading (read-only methods only, mutations still default-deny). Same PR also fixes the preset/policy mix behind the full-shell 403 storm (PUT restrictions now seeds the default policy and flips the account preset to learner). 22 regression tests included, verified on a live multi-user deployment.
If the maintainers do move to an explicit learner-surface list instead of growing the whitelist per report, the parametrized test in that PR (test_learning_surface_map.py) doubles as a machine-readable spec of which surfaces belong where — happy to rework the PR onto that structure if a direction is chosen.
Fixed: #1231 (merged 2026-09-07) maps /api/courses to the reading surface and surfaces the server denial instead of an empty state; #1323 (2026-09-23) extends the map to /api/mastery-paths and read-only /api/knowledge-bases. Covered by tests/multi_user/test_learning_surface_map.py. The wider default-deny learner policy is a separate design issue. This can be closed.
@larryluozhang — #1231 (merged 2026-09-07) addresses this and shipped in v1.7.1.
Could you confirm and close if it's resolved? If not, a short note would help.
Following up on #1231. A maintainer kept this open for the learner-surface policy beyond /api/courses; can you confirm whether that remaining policy issue still blocks you, or whether #1323 covers it? If it is resolved, please close.
This looks like it's already fixed by PR #1231 (f31acc1): restore learner access to /api/courses (was 403). No reply needed, just leaving this for the record. Just a heads-up in case it's useful, no action needed on your end. Found with AI assistance.