Skip to content

fix(models): tolerate $sequence int/string/null in Document.fromMap #262

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

Conversation

sadji-zigadi
Copy link

What does this PR do?

  • Fixes a deserialization crash when "$sequence" is returned as a string or omitted.
  • Changes Document.$sequence to nullable (int?) and parses with:
    • $sequence: (map['\$sequence'] as num?)?.toInt(),
  • Prevents Null → int and String → int errors during fromMap.

Test Plan

  • Added/updated unit tests:
    • String "$sequence": "3"doc.$sequence == 3
    • Missing "$sequence"doc.$sequence == null
  • Ran:
    • dart format .
    • dart analyze
    • flutter test

Related PRs and Issues

Notes

  • This makes the field nullable, which is technically a public API change but aligns with real-world server responses (string or absent).
  • If you prefer to keep the field non-nullable, I can switch to:
    • final int $sequence;
    • fromMap: $sequence: (map['\$sequence'] as num?)?.toInt() ?? 0,
      which preserves the API and defaults missing values to 0.

Have you read the Contributing Guidelines on issues?

Yes.

Copy link

This library is auto-generated by the Appwrite SDK Generator, and does not accept pull requests directly. To learn more about how you can help us improve this SDK, please check the contributing guide.

@github-actions github-actions bot closed this Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant