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: '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>' with permissions in a document #162

Closed
2 tasks done
ande4485 opened this issue Jul 14, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ande4485
Copy link

ande4485 commented Jul 14, 2023

👟 Reproduction steps

  1. create a document in a collection with permissions
adPanelUserDatabase.createDocument(
       databaseId: databaseId,
       collectionId: collectionAdPanelUser,
       documentId: appUser.idDatabase!,
       data: appUser.toJson(),
       permissions: [
         Permission.write(Role.user(appUser.idDatabase!)),
         Permission.update(Role.user(appUser.idDatabase!)),
         Permission.read(Role.users()),
         Permission.delete(Role.user(appUser.idDatabase!))
       ]);
  1. After make an getDocument:
 await adPanelUserDatabase.getDocument(
          databaseId: databaseId,
          collectionId: collectionAdPanelUser,
          documentId: idUser);

👍 Expected behavior

No error throws

👎 Actual Behavior

I got '_Map<String, dynamic>' is not a subtype of type 'List' , because in this line :

factory Document.fromMap(Map<String, dynamic> map) {
    return Document(
      $id: map['\$id'].toString(),
      $collectionId: map['\$collectionId'].toString(),
      $databaseId: map['\$databaseId'].toString(),
      $createdAt: map['\$createdAt'].toString(),
      $updatedAt: map['\$updatedAt'].toString(),
      $permissions: map['\$permissions'],
      data: map,
    );
  }

Line 41 in document.dart
$permissions are a List but map['$permissions'] are a map.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Linux

🧱 Your Environment

Flutter appwrite 9.0.1.
Flutter 3.10.6
Appwrite Cloud

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

@ande4485 ande4485 added the bug Something isn't working label Jul 14, 2023
@lohanidamodar
Copy link
Member

lohanidamodar commented Jul 16, 2023

@ande4485 I'm following your steps using Appwrite cloud and Appwrite Flutter SDK 9.0.1 but I'm unable to reproduce the issue.

Also with Appwrite cloud, it's recommended to use Flutter Appwrite SDK 8.x.x instead of 9.x.x

Let us know if using 8.x.x solves the issue?

@lohanidamodar lohanidamodar self-assigned this Jul 16, 2023
@ande4485
Copy link
Author

@lohanidamodar , thank you for your message, but even with appwrite: ^8.3.0 I have always this error.
If I test with latest version with appwrite on Docker and with flutter pub appwrite: 9.x.x, I have no problem.

@stnguyen90
Copy link
Contributor

@ande4485, you're probably facing appwrite/appwrite#5661 beacuse of duplicate permissions:

         Permission.write(Role.user(appUser.idDatabase!)),
         Permission.update(Role.user(appUser.idDatabase!)),
         Permission.read(Role.users()),
         Permission.delete(Role.user(appUser.idDatabase!))

because write is an alias for update + delete. So, you should just do:

         Permission.write(Role.user(appUser.idDatabase!)),
         Permission.read(Role.users())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants