Skip to content

🐛 Bug Report: TypeError when deserializing $sequence field from String to int #261

@Esseker-Dev

Description

@Esseker-Dev

👟 Reproduction steps

Bug Description

The Appwrite Dart SDK fails to deserialize documents containing the $sequence field when it's returned as a String instead of an int.

Steps to Reproduce

  1. Create a collection with documents in Appwrite Cloud
  2. Use the Dart SDK to call databases.listDocuments()
  3. The SDK throws: TypeError: "1": type 'String' is not a subtype of type 'int'

👍 Expected behavior

Expected Behavior

The SDK should handle the $sequence field correctly regardless of whether it's returned as a String or int.

👎 Actual Behavior

Actual Behavior

The SDK fails with a TypeError when $sequence is a String.

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Windows

🧱 Your Environment

Environment

  • Appwrite SDK: ^17.1.0
  • Dart SDK version: 3.8.1 (stable) (Wed May 28 00:47:25 2025 -0700) on "windows_x64"
  • Flutter: 3.32.8 • channel stable

Additional Information

  • The $sequence field is an internal Appwrite field that auto-increments
  • The API returns it as a String: "$sequence": "3"
  • The SDK expects it as an int: "$sequence": 3
  • This is a type mismatch in the SDK's deserialization logic

Workaround

Using direct HTTP calls with manual JSON parsing works correctly:

final response = await http.get(Uri.parse(url), headers: headers);
final data = json.decode(response.body);
// Manual filtering of system fields works fine

Reproduction Code

final response = await databases.listDocuments(
  databaseId: 'your_db_id',
  collectionId: 'your_collection_id',
);
// Fails with TypeError when document contains $sequence field


### 👀 Have you spent some time to check if this issue has been raised before?

- [x] I checked and didn't find similar issue

### 🏢 Have you read the Code of Conduct?

- [x] I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)

Metadata

Metadata

Assignees

No one assigned

    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