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's Static IP
Is it possible to have static. IP Address instead of Dynamic IP for getting the IP Address whitelist
- How to use dart workspaces to deploy a f...
Hello, I'm developing a Flutter application and I would like to leverage dart pub workspaces to deploy a function with a dart runtime as advertised here : http...
- [SOLVED] Unable to push function from AP...
When trying to push functions from Gitlab CI (with an API KEY and using the CLI), i saw that i was unable to push functions. ``` $ appwrite client --endpoint $...