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: Missing null check in Document.fromMap factory #175

Closed
2 tasks done
joern-h opened this issue Sep 15, 2023 · 2 comments
Closed
2 tasks done

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

joern-h opened this issue Sep 15, 2023 · 2 comments
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

@stnguyen90
Copy link
Contributor

Closing as duplicate of appwrite/appwrite#6158

@stnguyen90 stnguyen90 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
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

2 participants