AOSSIE-Org / AOSSIE-Org/Resonate

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

Offen
#778 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Dart
Sterne
344
Forks
350
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.