appwrite / appwrite/appwrite

🐛 Bug Report: User object empty prefs field is an array instead of an object

Offen
#6,360 2 Kommentare 1 Reaktion 1 zugewiesene Person Beansprucht von @stnguyen90 Auf GitHub ansehen
api / realtime bug product / functions
Vorherrschende Sprache
TypeScript
Sterne
57.4k
Forks
5.7k
Ø Merge
16 Std. 13 Min.
Gemergte PRs (30 T.)
297

Beschreibung

### 👟 Reproduction steps

When a `users.*.delete` event triggers a cloud function for a user that has empty preferences, the User object `prefs` is an array instead of an object.

**Reproducible code**

````
Future main(final context) async {
final client = Client()
.setEndpoint(Platform.environment['APPWRITE_ENDPOINT']!)
.setProject(Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'])
.setKey(Platform.environment['API_KEY']);

try {
final user = User.fromMap(context.req.body);

await Databases(client).deleteDocument(
databaseId: Platform.environment['DATABASE_ID']!,
collectionId: Platform.environment['USERS_COLLECTION_ID']!,
documentId: user.$id,
);

return context.res.empty();
} on Exception catch (e, stack) {
context.error('$e \n $stack');

return context.res.send('Server error', 500);
}
}
````

### 👍 Expected behavior

The User object from `context.req.body` should have `prefs:{}`

### 👎 Actual Behavior

The User object from `context.req.body` has `prefs:[]`

### 🎲 Appwrite version

Appwrite Cloud

### 💻 Operating system

MacOS

### 🧱 Your Environment

Appwrite 1.4 cloud functions

runtime: dart 2.17.0
dart_appwrite: 8.0.0

### 👀 Have you spent some time to check if this issue has been raised before?

- [X] I checked and didn't find similar issue

### 🏢 Have you read the Code of Conduct?

- [X] I have read the [Code of Conduct](https://github.com/appwrite/.github/blob/main/CODE_OF_CONDUCT.md)

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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