BulkRoleCache.prefetch caches the legacy loop variable for openedx-authz roles

Aperta
#39,168 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
django, python

Direzione di ricerca

Start in common/djangoapps/student/roles.py at BulkRoleCache.prefetch and trace both the legacy and openedx-authz loops. Reproduce the authz-only and mixed-batch cases with the described in-memory fixtures, then add regression coverage showing each user/course cache contains its own assignment and both cases pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Checked 2026-09-30: master source at ca039029e4918f02903b1c7d62adf8b3ad74f75b and release/verawood source at 18ce9a9c2b20c745b0ee94f615c13855acd9624b. Both carry this code path. This is a source diagnostic; no upstream full integration suite or production mutation ran.

The openedx-authz loop iterates over its own role but inserts compat_role, which belongs to the preceding legacy loop.

Reproduction:

  1. Give an author an openedx-authz course assignment with no legacy CourseAccessRole rows in the prefetch batch.
  2. Call BulkRoleCache.prefetch for that batch. The first authz assignment raises UnboundLocalError.
  3. Repeat with a legacy role present, on another course. The authz course cache receives the last legacy role instead of that author's authz role.

An isolated execution of the current native function body with in-memory model/role fixtures reproduces both outcomes on master and Verawood. Changing only the insertion to the current authz loop role makes both controls cache the expected authz role. This is not a full Django/authorization integration claim.

Expected: authz-only and mixed batches cache their own per-user/course assignments, independent of which legacy role was last enumerated. Suggested regression controls are both cases above, including distinct courses and users.

Duplicate checks: current issue/PR searches for BulkRoleCache and compat_role. #38984 concerns platform-wide scope conversion, not this loop variable; #38943 concerns grade-report query cost. I found no report for this insertion case in those results.

Lingua principale
Python
Stelle
8.2k
Fork
4.4k
Merge medio
2g 10h
PR unite (30g)
40

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openedx/openedx-platform

Tutte le issue di openedx/openedx-platform

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.