Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis pull request introduces version 21.0.0 of the Appwrite Flutter SDK with significant API refinements. The changes include a new type-safe Channel routing API for building resource paths, expanded Query filtering capabilities with regex, exists, notExists, and elemMatch methods, and new enum types (BrowserPermission and Roles) to replace string-based parameters. Multiple service methods now accept strongly-typed enum parameters instead of strings (permissions, roles). The File model gains encryption and compression fields. Documentation examples are updated to use namespace-qualified enum references. The Realtime.subscribe method now accepts List to support both string channels and Channel builder objects. Version references and SDK headers are bumped to 21.0.0. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
docs/examples/storage/get-file-preview.md (1)
1-1:⚠️ Potential issue | 🔴 CriticalAdd missing
enumsimport.The code uses
enums.ImageGravityandenums.ImageFormaton lines 15, 23, 37, and 45, but the required import is missing. The Appwrite Flutter SDK does not export these enums frompackage:appwrite/appwrite.dart—they must be imported frompackage:appwrite/enums.dartseparately.Add the alias import:
Fix
import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/enums.dart' as enums;docs/examples/account/create-o-auth-2-session.md (1)
1-10:⚠️ Potential issue | 🟡 MinorAdd the missing
enumsimport.The snippet references
enums.OAuthProviderbut only importsappwrite.dart, which does not re-export the enums alias. This will cause a compilation error. Add the explicit import:import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/enums.dart' as enums;Note: This same issue affects other documentation examples (teams, storage, functions, avatars).
lib/src/models/file.dart (1)
60-75:⚠️ Potential issue | 🟠 MajorHandle null/missing values for
encryptionandcompressionfields infromMap.The current implementation assumes both fields are always present in the API response. Line 73 assigns
map['encryption']directly without null safety, and line 74 calls.toString()on a potentially null value. If the server omits these fields or returns null,fromMapwill either fail at assignment (forencryption) or at runtime (forcompression). This is especially risky given thatencryptionmust be aboolandcompressiondocumentation indicates valid values are "none", "gzip", or "zstd".Apply safe defaults aligned with field semantics:
🛠️ Proposed fix
- encryption: map['encryption'], - compression: map['compression'].toString(), + encryption: map['encryption'] as bool? ?? false, + compression: map['compression']?.toString() ?? 'none',
🤖 Fix all issues with AI agents
In `@docs/examples/avatars/get-screenshot.md`:
- Around line 19-33: The example uses the enums alias (e.g., enums.Theme,
enums.Timezone, enums.BrowserPermission, enums.ImageFormat) but never imports
it; add an import for the enums alias from the SDK/module used in this project
(so the example compiles), then reference enums throughout the snippet; update
the top of the snippet to import the enums symbol (so get-screenshot.md examples
19-33 and similarly 50-64 compile).
In `@lib/src/realtime_mixin.dart`:
- Around line 169-188: The code currently accepts any Object in
subscribeTo(List<Object> channels) and coerces via _channelToString, which can
yield invalid names; fix by validating channel types before adding them: in
subscribeTo iterate channels and for each ensure it is either a String or a
Channel instance (the type you use in the codebase), otherwise throw an
ArgumentError naming the offending value; implement this validation either at
the start of subscribeTo or by updating _channelToString to perform the type
check and throw ArgumentError for unsupported types; continue to use the
validated channelStrings with _channels.addAll, RealtimeSubscription(...),
controller.close(), and _cleanup as before.
| theme: enums.Theme.dark, // optional | ||
| userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional | ||
| fullpage: true, // optional | ||
| locale: 'en-US', // optional | ||
| timezone: Timezone.africaAbidjan, // optional | ||
| timezone: enums.Timezone.americaNewYork, // optional | ||
| latitude: 37.7749, // optional | ||
| longitude: -122.4194, // optional | ||
| accuracy: 100, // optional | ||
| touch: true, // optional | ||
| permissions: ["geolocation","notifications"], // optional | ||
| permissions: [enums.BrowserPermission.geolocation, enums.BrowserPermission.notifications], // optional | ||
| sleep: 3, // optional | ||
| width: 800, // optional | ||
| height: 600, // optional | ||
| quality: 85, // optional | ||
| output: ImageFormat.jpg, // optional | ||
| output: enums.ImageFormat.jpeg, // optional |
There was a problem hiding this comment.
Add the missing enums import for the updated snippet.
The example now uses enums.* but doesn’t import the alias, so it won’t compile as shown.
💡 Suggested fix
-import 'package:appwrite/appwrite.dart';
+import 'package:appwrite/appwrite.dart';
+import 'package:appwrite/enums.dart' as enums;Also applies to: 50-64
🤖 Prompt for AI Agents
In `@docs/examples/avatars/get-screenshot.md` around lines 19 - 33, The example
uses the enums alias (e.g., enums.Theme, enums.Timezone,
enums.BrowserPermission, enums.ImageFormat) but never imports it; add an import
for the enums alias from the SDK/module used in this project (so the example
compiles), then reference enums throughout the snippet; update the top of the
snippet to import the enums symbol (so get-screenshot.md examples 19-33 and
similarly 50-64 compile).
| /// Convert channel value to string | ||
| /// Handles String and Channel instances (which have toString()) | ||
| String _channelToString(Object channel) { | ||
| return channel is String ? channel : channel.toString(); | ||
| } | ||
|
|
||
| RealtimeSubscription subscribeTo(List<Object> channels) { | ||
| StreamController<RealtimeMessage> controller = StreamController.broadcast(); | ||
| _channels.addAll(channels); | ||
| final channelStrings = | ||
| channels.map((ch) => _channelToString(ch)).toList().cast<String>(); | ||
| _channels.addAll(channelStrings); | ||
| Future.delayed(Duration.zero, () => _createSocket()); | ||
| int id = DateTime.now().microsecondsSinceEpoch; | ||
| RealtimeSubscription subscription = RealtimeSubscription( | ||
| controller: controller, | ||
| channels: channels, | ||
| channels: channelStrings, | ||
| close: () async { | ||
| _subscriptions.remove(id); | ||
| controller.close(); | ||
| _cleanup(channels); | ||
| _cleanup(channelStrings); |
There was a problem hiding this comment.
Guard against unsupported channel types.
List<Object> currently accepts anything and coerces via toString(), which can silently generate invalid channel names (e.g., “Instance of …”). Consider enforcing String or Channel and throwing ArgumentError otherwise.
🧩 Suggested fix
+import '../channel.dart';
...
/// Convert channel value to string
/// Handles String and Channel instances (which have toString())
String _channelToString(Object channel) {
- return channel is String ? channel : channel.toString();
+ if (channel is String) return channel;
+ if (channel is Channel) return channel.toString();
+ throw ArgumentError.value(
+ channel, 'channel', 'Expected String or Channel');
}🤖 Prompt for AI Agents
In `@lib/src/realtime_mixin.dart` around lines 169 - 188, The code currently
accepts any Object in subscribeTo(List<Object> channels) and coerces via
_channelToString, which can yield invalid names; fix by validating channel types
before adding them: in subscribeTo iterate channels and for each ensure it is
either a String or a Channel instance (the type you use in the codebase),
otherwise throw an ArgumentError naming the offending value; implement this
validation either at the start of subscribeTo or by updating _channelToString to
perform the type check and throw ArgumentError for unsupported types; continue
to use the validated channelStrings with _channels.addAll,
RealtimeSubscription(...), controller.close(), and _cleanup as before.
This PR contains updates to the Flutter SDK for version 21.0.0.