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
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...
- Inquiry: How to Reduce Cold Start Durati...
Hey! I was using Python for the function runtime, but after reading that Go has the fastest runtime, I switched my code over to Go. However, I'm still seeing co...
- After a GET request is passed to functio...
Create execution in the console can normally retrieve the get parameters。WHy?