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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Missing null check in Document.fromMap factory #175

Open
2 tasks done
joern-h opened this issue Sep 15, 2023 · 1 comment
Open
2 tasks done

馃悰 Bug Report: Missing null check in Document.fromMap factory #175

joern-h opened this issue Sep 15, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@joern-h
Copy link

joern-h commented Sep 15, 2023

馃憻 Reproduction steps

Databases listDocuments with select query that does not include $permissions field

馃憤 Expected behavior

Document object should be constructed with an empty $permissions list

Proposed change:

  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'] ?? [], // add null check
      data: map,
    );
  }

馃憥 Actual Behavior

factory Document.fromMap throws exception: 'Null' is not a subtype of type 'List'

  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'], // null exception 
      data: map,
    );
  }

馃幉 Appwrite version

Different version (specify in environment)

馃捇 Operating system

Linux

馃П Your Environment

Appwrite 1.4.2
Flutter SDK: 11.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?

@joern-h joern-h added the bug Something isn't working label Sep 15, 2023
@joern-h joern-h changed the title 馃悰 Bug Report: type 'Null' is not a subtype of type 'List<dynamic>' 馃悰 Bug Report: Missing null check in Document.fromMap factory Sep 15, 2023
@joern-h
Copy link
Author

joern-h commented Sep 20, 2023

This is related to appwrite/appwrite#6158

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

1 participant