According to the docs, the prefs field should be an object but when I get it from functions it's an array
https://appwrite.io/docs/models/user
{"$id":"65153d362dcf3f9f27bf","$createdAt":"2023-09-28T08:45:42.189 00:00","$updatedAt":"2023-09-28T08:45:42.189 00:00","name":"sdfdfdf","registration":"2023-09-28T08:45:42.187 00:00","status":true,"labels":[],"passwordUpdate":"2023-09-28T08:45:42.187 00:00","email":"dfsdsf@dssd.adsasd","phone":"","emailVerification":false,"phoneVerification":false,"prefs":[],"accessedAt":"2023-09-28T08:45:42.187 00:00"}
Hey 👋
What SDK are you using?
Dart server SDK
Weird can't see any obvious reason for this in the code.
What version of dart and dart SDK are you running?
Dart 2.17 SDK 8.0.0
To give you some context, this is the function it's triggered by an users.*.delete event
Future<dynamic> 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); }
Sorry I can't format it on mobile
Users.FromMap() fails because the user object from context.req.body preferences is an array instead of an object
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
weird....we should be converting it if it's empty...but maybe the bug is somewhere else. Would you be able to create a GitHub issue for this?
Done
Recommended threads
- Cloud function deploy stucks in processi...
Been trying for the last hours to deploy my function but for whatever reason, alwasy stuck on processing!
- [SOLVED] curl error Number: 6 — function...
Hello, I invested a lot of time in this error in a fresh install of appwrite 1.8.1 and lasted until fix, this if for helping anyone that can have the same weird...
- ClientException with SocketException: Cl...
hi <@564158268319203348> i have noticed this 500 status code in my function requests, it seems its not able to connect to the internet in the function as reque...