AOSSIE-Org / AOSSIE-Org/Resonate
Prevent runtime crashes from unsafe .first access on realtime events and query results
- Lingua principale
- Dart
- Stelle
- 344
- Fork
- 350
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### 🐛 Describe the bug
Description
A clear and concise description of what the bug is.
Several controllers in the Resonate module access .first on lists returned from:
Appwrite realtime streams (data.events)
Appwrite database queries (documents)
without verifying that the list is non-empty.
If these lists are empty, calling .first throws a runtime exception and crashes the application.
This can occur during:
Realtime event handling
Query result processing
Unlike/delete operations
Participant lookup logic
Sample code to reproduce the problem
Unsafe patterns found in the codebase:
```dart
if (data.events.first.endsWith('.update')) {
// handle update
}
return value.documents.first;
```
If events or documents is empty, these lines throw:
```dart
Unhandled exception:
StateError: No element
```
The error message you got, with the full traceback.
Typical runtime error:
```dart
Unhandled exception:
StateError: No element
```
This occurs when .first is accessed on an empty list returned by:
realtime.subscribe().stream.listen
databases.listDocuments()
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.