AOSSIE-Org / AOSSIE-Org/Resonate

Potential StateError when accessing .first on empty documents list in removeUserFromSubscriberList

Aperta
#778 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Dart
Stelle
344
Fork
350
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 🐛 Describe the bug

## A clear and concise description of what the bug is.

In `removeUserFromSubscriberList` (lib/controllers/upcomming_rooms_controller.dart),
the result of `databases.listDocuments()` is accessed using:

value.documents.first

If `listDocuments()` returns an empty list, calling `.first` will throw:

StateError: No element

This can cause a runtime crash when attempting to remove a user from the subscriber list if no matching subscription document exists.

---

## Sample code to reproduce the problem

If the database contains no document matching:

- userId = current user id
- upcomingRoomId = provided id

Then this line:

value.documents.first

will throw a `StateError` because the list is empty.

A simplified reproduction:

```dart
final list = [];
print(list.first); // Throws StateError: No element

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.