[bug] `Device.manage_devices_group_templates` aborts early when any device lacks a config

Aperta Adatta ai principianti
#1,572 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@blade0g ci sta già lavorando.

Dal 28/11/2026.

Valutazione

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

Direzione di ricerca

Il bug si trova in AbstractDevice.manage_devices_group_templates in openwisp_controller/config/base/device.py, intorno alle righe 500-532. Nel ciclo su device_ids, un return viene eseguito quando un dispositivo non ha ancora una configurazione dopo create_default_config(); dovrebbe invece passare al dispositivo successivo. Cambialo in continue, quindi aggiungi un test di regressione con un elenco misto di dispositivi in cui il primo non ha una configurazione e il secondo ha dei template. È completato quando i template di gruppo del secondo dispositivo vengono aggiornati.

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

Descrizione

bug

Describe the bug

In AbstractDevice.manage_devices_group_templates, when iterating over device_ids, if a device has no config and create_default_config() does not create one (for example, when the target group has no templates or group_id is None), the method executes return instead of continue. This exits the loop immediately and skips updating group templates for all subsequent devices.

Steps To Reproduce

  1. Call Device.manage_devices_group_templates([device1.pk, device2.pk], [old_group1.pk, old_group2.pk], target_group.pk) (for example, via the change_group admin action on multiple devices).
  2. Ensure device1 has no Config object and target_group has no templates (or target_group is None).
  3. Ensure device2 has a Config object with templates from old_group2.
  4. Observe that device2.config.manage_group_templates(...) is never called, leaving device2's templates unchanged.

Expected behavior

When a device has no config after create_default_config(), the method should continue to the next device rather than returning, so remaining devices still have their group templates updated.

Proposed fix

Replace return with continue and add a regression test covering a mixed list of devices.

System Information:

  • OS: Arch Linux
  • Python Version: 3.11.15
  • Django Version: 5.2.19
  • Browser and Browser Version (if applicable): N/A
Lingua principale
Python
Stelle
800
Fork
354
Merge medio
1g 8h
PR unite (30g)
15

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 openwisp/openwisp-controller

Tutte le issue di openwisp/openwisp-controller

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.