Skip to content

🐛 Bug Report: Document.fromMap crashes on $sequence if backend returns String #1129

@PhilippBau

Description

@PhilippBau

👟 Reproduction steps

  • Use Appwrite SDK 17.1.0 with Appwrite Cloud
  • Call Databases.getDocument() on any collection
  • SDK receives a document with $sequence as a String
  • Runtime type error occurs during Document.fromMap() parsing

👍 Expected behavior

Document.fromMap() should safely parse $sequence and handle both int and String types gracefully. The SDK should be defensive against backend type inconsistencies.

👎 Actual Behavior

After updating to Appwrite Flutter SDK 17.1.0, calls to Databases.getDocument() crash with the following runtime error:
type 'String' is not a subtype of type 'int'
The crash occurs in Document.fromMap at line 42:
dartDocument.fromMap (package:appwrite/src/models/document.dart:42:21)
Root Cause: The newly added $sequence field in version 17.1.0 is expected to be an int, but Appwrite Cloud is returning it as a String, causing a type mismatch.

📋 Stack Trace

flutter: Error fetching startup config data: type 'String' is not a subtype of type 'int'
flutter: Stack trace: 
#0      new Document.fromMap (package:appwrite/src/models/document.dart:42:21)
#1      Databases.getDocument (package:appwrite/services/databases.dart:94:28)
<asynchronous suspension>
#2      DbUtilStartUpConfig.getStartupConfigData (package:xxx/backend/appwrite/database/startup_check.dart:27:33)
<asynchronous suspension>
#3      _StartupChecksScreenState._runStartupChecks (package:xxx/startup_check_screen.dart:55:11)
<asynchronous suspension>

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

MacOS

🧱 Your Environment

No response

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions