Skip to content

Conversation

@pranjal29092005
Copy link

@pranjal29092005 pranjal29092005 commented Dec 13, 2025

🐛 Problem

With Appwrite v1.8.0, relationship fields are no longer fetched by default when querying documents. This breaking change caused the production version of Resonate to fail after upgrading to Appwrite SDK v17.x (currently v20.3.1).

Impact:

  • Null reference errors when accessing related document data
  • Missing user profiles in participant lists
  • Broken chat messages (missing avatars/names)
  • Failed room joins due to incomplete data

Root Cause: All database queries using databases.listDocuments() and databases.getDocument() that access relationship fields were returning incomplete data.

💡 Solution

Added Query.select(["*"]) to all database queries that access relationship fields, implementing Appwrite's new opt-in relationship loading mechanism.

Example:

// Before (broken in v1.8.0+)
await databases.listDocuments(
  databaseId: masterDatabaseId,
  collectionId: participantsCollectionId,
  queries: [Query.equal("roomId", roomId)],
);

// After (v1.8.0 compatible)
await databases.listDocuments(
  databaseId: masterDatabaseId,
  collectionId: participantsCollectionId,
  queries: [
    Query.equal("roomId", roomId),
    Query.select(["*"]),  // ✅ Explicitly load relationships
  ],
);

📊 Changes Summary

Files Modified: 11
Lines Changed: +43 insertions, -6 deletions

Modified Components:

  • ✅ Room management (rooms_controller.dart, single_room_controller.dart, room_service.dart)
  • ✅ Chat systems (room_chat_controller.dart, pair_chat_controller.dart)
  • ✅ User profiles & friends (user_profile_controller.dart, friends_controller.dart, friend_calling_controller.dart)
  • ✅ Authentication (auth_state_controller.dart, email_verify_controller.dart, change_email_controller.dart)

✅ Testing

Automated

  • Code compiles without errors
  • Follows Dart coding conventions
  • Conventional commit format
  • No breaking changes to existing APIs

Manual Testing

  • Room listing with participant avatars
  • Room joining with complete data
  • Chat messages with user info
  • User profile loading
  • Friends list functionality
  • Authentication flows

📚 References

🎯 Future Optimization

Current implementation uses wildcard ["*"] for safety. Future PRs can optimize by selecting specific fields:

Query.select(["fieldName", "relationship.specificField"])

📝 Verification Steps

For Reviewers:

  1. Verify all relationship queries include Query.select(["*"])
  2. Check pattern consistency across all 11 files
  3. Confirm no unrelated changes

For Testing:

git checkout fix/appwrite-v1.8-relationship-loading
flutter pub get
flutter analyze
flutter test

🔗 Related Issues

Fixes #636


Ready for Review
This PR restores critical functionality broken by Appwrite v1.8.0. The fix is minimal, focused, and follows established patterns.

Summary by CodeRabbit

Bug Fixes

  • Resolved data retrieval issues to ensure complete user and room information displays across profiles, friend lists, room details, and messaging sections.
  • Enhanced data availability and consistency in room management, chat features, and user interactions.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

🎉 Welcome @pranjal29092005!
Thank you for your pull request! Our team will review it soon. 🔍

  • Please ensure your PR follows the contribution guidelines. ✅
  • All automated tests should pass before merging. 🔄
  • If this PR fixes an issue, link it in the description. 🔗

We appreciate your contribution! 🚀

@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds Query.select(["*"]) to multiple Appwrite database queries across controllers and services to explicitly fetch all document fields. This addresses Appwrite SDK v1.8.0+ behavior changes where relationship fields no longer retrieve by default, ensuring complete document data is available for processing.

Changes

Cohort / File(s) Summary
Auth & Profile Controllers
lib/controllers/auth_state_controller.dart, lib/controllers/change_email_controller.dart, lib/controllers/email_verify_controller.dart, lib/controllers/user_profile_controller.dart
Added Query.select(["*"]) to queries in setUserProfileData, isEmailAvailable, verification status checks, and fetchUserFollowers to retrieve all document fields.
Friend & Social Controllers
lib/controllers/friend_calling_controller.dart, lib/controllers/friends_controller.dart
Added Query.select(["*"]) to getDocument/listDocuments calls for friend data and call participant retrieval.
Chat & Room Controllers
lib/controllers/pair_chat_controller.dart, lib/controllers/room_chat_controller.dart, lib/controllers/rooms_controller.dart, lib/controllers/single_room_controller.dart
Added Query.select(["*"]) to queries fetching room documents, participant profiles, messages, and replyTo references.
Room Service
lib/services/room_service.dart
Added Query.select(["*"]) to participant lookup, room retrieval, and participant listing/removal queries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Rationale: Highly homogeneous changes—identical pattern (adding Query.select(["*"])) repeated across multiple files with minimal variation in context. No complex logic, error handling changes, or control flow modifications.
  • Areas requiring attention:
    • Verify Query.select(["*"]) is the correct method signature for Appwrite SDK v17.x
    • Confirm that explicit field selection doesn't negatively impact performance (especially in methods with high query volume like loadMessages or listDocuments with many iterations)
    • Spot-check one or two controllers (e.g., room_chat_controller, rooms_controller) to ensure field selection is applied consistently across similar query patterns

Possibly related PRs

Suggested labels

app-update

Suggested reviewers

  • M4dhav

Poem

🐰 A hop through Appwrite's fields so wide,
Query.select(["*"]) as our guide!
With v1.8.0's breaking change in sight,
We fetch all data, now burning bright ✨
No more relationship shadows to fight,
Full documents dance in the API's light! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main change: adding explicit relationship field selection to address Appwrite v1.8.0 compatibility, which matches the core objective of the PR.
Linked Issues check ✅ Passed The PR comprehensively addresses all coding requirements from issue #636 by adding Query.select(["*"]) to all database queries accessing relationship fields across 11 files, preventing null references and restoring functionality after the Appwrite v1.8.0 breaking change.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to adding Query.select(["*"]) for relationship field loading; no unrelated modifications, refactoring, or feature additions beyond the stated objective are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
lib/controllers/change_email_controller.dart (1)

37-52: LGTM! Ensures complete document retrieval.

The addition of Query.select(["*"]) ensures full document data is available. As noted in the PR description, the wildcard selection is used for safety and can be optimized later to select only required fields for existence checks.

Future optimization: Since this function only checks email availability via document count, consider selecting minimal fields (e.g., just the email field) instead of all fields to reduce bandwidth:

  queries: [
    Query.equal('email', changedEmail),
-   Query.select(["*"]),
+   Query.select(["email"]),
  ],
lib/controllers/auth_state_controller.dart (1)

349-358: LGTM! Comprehensive fix applied across all queries.

All database queries in this file now explicitly request full document data. As noted in the PR description, the wildcard ["*"] approach is safe for initial compatibility. Consider optimizing to specific field lists in a future iteration to reduce data transfer overhead.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b063ecb and 6dc7b83.

📒 Files selected for processing (11)
  • lib/controllers/auth_state_controller.dart (5 hunks)
  • lib/controllers/change_email_controller.dart (1 hunks)
  • lib/controllers/email_verify_controller.dart (1 hunks)
  • lib/controllers/friend_calling_controller.dart (3 hunks)
  • lib/controllers/friends_controller.dart (1 hunks)
  • lib/controllers/pair_chat_controller.dart (3 hunks)
  • lib/controllers/room_chat_controller.dart (3 hunks)
  • lib/controllers/rooms_controller.dart (3 hunks)
  • lib/controllers/single_room_controller.dart (3 hunks)
  • lib/controllers/user_profile_controller.dart (1 hunks)
  • lib/services/room_service.dart (5 hunks)
🔇 Additional comments (28)
lib/controllers/user_profile_controller.dart (1)

122-127: LGTM! Correctly fetches relationship fields.

The addition of Query.select(["*"]) ensures the followers relationship field (accessed at line 130) is properly loaded with Appwrite SDK v20.3.1, addressing the v1.8.0 breaking change.

lib/controllers/email_verify_controller.dart (1)

116-124: LGTM! Ensures complete user document retrieval.

The addition of Query.select(["*"]) guarantees all fields of the user document are fetched, including any relationship fields that may be needed for verification status checks.

lib/controllers/friend_calling_controller.dart (3)

124-130: LGTM! Ensures complete call document retrieval.

The addition of Query.select(["*"]) ensures all fields are available for FriendCallModel.fromJson() deserialization at line 130, including any relationship fields.


154-160: LGTM! Ensures complete call document retrieval.

The addition of Query.select(["*"]) ensures all fields are available for FriendCallModel.fromJson() deserialization at line 160.


174-181: LGTM! Ensures complete call document retrieval.

The addition of Query.select(["*"]) ensures all fields are available for FriendCallModel.fromJson() deserialization at line 181.

lib/services/room_service.dart (5)

37-46: LGTM! Ensures complete participant document retrieval.

The addition of Query.select(["*"]) ensures all participant fields are available for processing, including any relationship fields that may be present.


68-75: LGTM! Ensures room document includes totalParticipants.

The addition of Query.select(["*"]) ensures the totalParticipants field (accessed at line 79) is properly loaded, which is critical for accurate participant count management.


183-191: LGTM! Ensures complete participant document retrieval.

The addition of Query.select(["*"]) ensures all participant fields are available for the deletion loop.


227-232: LGTM! Ensures room document includes totalParticipants.

The addition of Query.select(["*"]) ensures the totalParticipants field (accessed at line 254) is properly loaded for participant count validation.


235-244: LGTM! Ensures complete participant document retrieval.

The addition of Query.select(["*"]) ensures all participant fields are available for counting and deletion operations.

lib/controllers/pair_chat_controller.dart (3)

132-138: LGTM! Ensures participant profile data is loaded.

The addition of Query.select(["*"]) ensures the profileImageUrl field (accessed at line 138) is properly loaded from the user document.


142-149: LGTM! Ensures participant profile data is loaded.

The addition of Query.select(["*"]) ensures the profileImageUrl field (accessed at line 148) is properly loaded from the user document.


208-221: LGTM! Ensures complete pair request document retrieval.

The addition of Query.select(["*"]) ensures all fields are available for ResonateUser.fromJson() deserialization at line 230, including any relationship fields.

lib/controllers/single_room_controller.dart (3)

67-73: LGTM! Ensures complete user document retrieval.

The addition of Query.select(["*"]) ensures all user fields (email, name, profileImageUrl) accessed at lines 77-79 are properly loaded, including any relationship fields.


115-126: LGTM! Ensures complete participant document retrieval.

The addition of Query.select(["*"]) ensures all participant fields are available for processing in the loop at line 128, including any relationship fields.


243-251: LGTM! Ensures complete participant document retrieval.

The addition of Query.select(["*"]) ensures all participant fields are available when fetching the participant document ID.

lib/controllers/room_chat_controller.dart (3)

47-54: LGTM! Ensures complete message document retrieval.

The addition of Query.select(["*"]) ensures all message fields are available for processing, including any relationship fields that may be present.


63-69: LGTM! Ensures replyTo relationship data is loaded.

The addition of Query.select(["*"]) ensures the replyTo document fields are properly loaded for deserialization at line 69, addressing the Appwrite v1.8.0 relationship loading behavior.


217-223: LGTM! Ensures replyTo relationship data is loaded.

The addition of Query.select(["*"]) ensures the replyTo document fields are properly loaded for real-time message updates, addressing the Appwrite v1.8.0 relationship loading behavior.

lib/controllers/auth_state_controller.dart (4)

206-211: LGTM! Relationship field loading fix applied correctly.

The addition of Query.select(["*"]) ensures the followers relationship field (accessed at line 218) is properly loaded with Appwrite v1.8.0+.


277-286: LGTM! Complete document data retrieval enabled.

Adding Query.select(["*"]) alongside Query.equal ensures subscribed room documents include all fields needed for registration token updates.


300-309: LGTM! Consistent pattern for created rooms.

The fix correctly mirrors the subscribed rooms approach, ensuring creator FCM tokens are accessible.


326-335: LGTM! Token removal flow updated correctly.

The removal flow correctly applies the same Query.select pattern to access registration tokens.

lib/controllers/rooms_controller.dart (4)

40-48: LGTM! Participant data loading fixed.

The addition of Query.select(["*"]) ensures complete participant documents are retrieved for avatar URL extraction (line 57).


51-56: LGTM! User document retrieval enhanced.

Adding Query.select(["*"]) ensures participant profile data, including the profileImageUrl, is fully loaded.


83-87: LGTM! Room listing data retrieval corrected.

The fix ensures all room fields (totalParticipants, adminUid, tags, etc.) are available when constructing AppwriteRoom objects (lines 61-71).


105-110: LGTM! Single room retrieval fixed.

The fix consistently applies the same pattern as getRooms, ensuring complete room data for single-room queries.

lib/controllers/friends_controller.dart (1)

98-103: LGTM! Friends relationship loading restored.

The addition of Query.select(["*"]) ensures the friends relationship field (accessed at line 104) is properly loaded, restoring friends list functionality with Appwrite v1.8.0+.

@pranjal29092005
Copy link
Author

Hi @M4dhav 👋

Thank you for maintaining this project!

I've submitted this PR as part of the Unstoppable Hackathon (team: Dev Engers) fix: add explicit relationship field selection for Appwrite v1.8.0 compatibility #652 addressing issue #652

Could you please approve the pending workflow when you have a moment? The automated checks are awaiting maintainer approval.

I'm available to address any feedback or make changes if needed. Thank you for your time! 🙏

Team Details:

Team Name: Dev Engers
Members: Pushkar Modi, Parth Raninga, Pranjal Yadav

@M4dhav M4dhav self-requested a review December 19, 2025 12:09
@M4dhav M4dhav added bug Something isn't working unstoppable-hackathon labels Dec 19, 2025
@M4dhav M4dhav changed the base branch from master to dev December 19, 2025 12:17
Copy link
Contributor

@M4dhav M4dhav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"*" operator will not load all fields, please see https://appwrite.io/docs/products/databases/legacy/queries#load-all-relationship-data for correct way to load fields. Also, please fix merge conflicts

@pranjal29092005
Copy link
Author

pranjal29092005 commented Dec 19, 2025 via email

@M4dhav
Copy link
Contributor

M4dhav commented Dec 19, 2025

Tests are failing, please check. Re-request for review when ready

@pranjal29092005
Copy link
Author

pranjal29092005 commented Dec 19, 2025 via email

@pranjal29092005 pranjal29092005 force-pushed the fix/appwrite-v1.8-relationship-loading branch from 1c82529 to 42055ef Compare December 19, 2025 13:38
@pranjal29092005 pranjal29092005 force-pushed the fix/appwrite-v1.8-relationship-loading branch from 42055ef to 7447130 Compare December 19, 2025 14:06
@pranjal29092005
Copy link
Author

sir i have fixed all issue and solved all merged conflict please review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working unstoppable-hackathon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes to Appwrite Relationships cause critical bugs

2 participants