AOSSIE-Org / AOSSIE-Org/Resonate

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

Ouverte
#778 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Dart
Étoiles
344
Forks
350
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

### 🐛 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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.