Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
Andree98 opened this issue Sep 29, 2023 · 2 comments
Open
2 tasks done
Assignees
Labels
api / realtime Fixes and upgrades for the Appwrite Realtime API. bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@Andree98
Copy link

👟 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<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);
  }
}

👍 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?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@Andree98 Andree98 added the bug Something isn't working label Sep 29, 2023
@Sooraj-s-98
Copy link
Contributor

Hey I would like to work on this issue

@stnguyen90 stnguyen90 added product / functions Fixes and upgrades for the Appwrite Functions. api / realtime Fixes and upgrades for the Appwrite Realtime API. labels Oct 11, 2023
@stnguyen90
Copy link
Contributor

@Sooraj-s-98, are you still interested in working on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api / realtime Fixes and upgrades for the Appwrite Realtime API. bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

3 participants