[cloud_firestore][Windows] Transaction read and commit errors lose the Firestore error code (reported as `unknown`)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- dart
- Lĩnh vực
- database, desktop-dev
Hướng nghiên cứu
Bắt đầu trong windows/cloud_firestore_plugin.cpp tại TransactionGet và trình xử lý hoàn tất giao dịch, so sánh cả hai đường dẫn với ParseError. Tái hiện trên Windows bằng các quy tắc từ chối thao tác đọc và xác minh rằng các thao tác đọc trong giao dịch và các commit thất bại báo cáo mã lỗi và thông báo của Firestore thay vì unknown. Xác nhận thay đổi bằng ví dụ giao dịch Dart được cung cấp và các kiểm tra plugin Windows liên quan.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is there an existing issue for this?
- I have searched the existing issues.
This is the same class of defect as #18550 (firebase_database on Windows), in cloud_firestore.
Which plugins are affected?
Other (Cloud Firestore)
Which platforms are affected?
Windows
Description
On Windows, a Firestore transaction that fails reaches Dart as FirebaseException(code: 'unknown') whatever Firestore actually returned. The same failure on a plain DocumentReference.get() reports the real code (permission-denied, unavailable, …), because that path goes through ParseError.
Two paths in windows/cloud_firestore_plugin.cpp build their error without the details map that ParseError provides:
-
TransactionGet, a read inside a transaction (L1260 at a646d55):result(FlutterError(error_message));That is the one-argument constructor, so the Firestore message lands in the error's code slot, with no message and no details.
-
The transaction completion handler, when the commit fails (L1160):
SendErrorOnPlatformThread(events_state_, "transaction_error", completed_future.error_message(), flutter::EncodableValue());
_flutterfire_internals' platformExceptionToFirebaseException reads the code only from details['code'] and falls back to unknown. It reads the message from details['message'], or else PlatformException.message. So:
- a failed transaction read becomes
[cloud_firestore/unknown]with an empty message, because the real message went intoPlatformException.code, which is discarded; - a failed commit becomes
[cloud_firestore/unknown], keeping the message but not the code.
Apps can't tell a rules or App Check refusal (permission-denied) from contention (aborted) or a transient network failure. Anything that retries or reports on the code misclassifies it: we retried a permanent permission-denied as if it were transient.
Observed: the read path in production, from a Windows desktop app. The stack ran through FirebaseFirestoreHostApi.transactionGet → MethodChannelTransaction.get and ended in FirebaseException: [cloud_firestore/unknown] with no message. Earlier in the same session, the same account's plain get() of another document failed with [cloud_firestore/permission-denied]. The commit path is from reading the code; it has the same shape.
Suggested fix (not yet compiled on Windows), giving both paths the shape ParseError already uses:
@@ TransactionStreamHandler completion
} else {
+ EncodableMap details;
+ details[EncodableValue("code")] =
+ EncodableValue(CloudFirestorePlugin::GetErrorCode(
+ static_cast<firebase::firestore::Error>(
+ completed_future.error())));
+ details[EncodableValue("message")] =
+ EncodableValue(completed_future.error_message());
SendErrorOnPlatformThread(events_state_, "transaction_error",
completed_future.error_message(),
- flutter::EncodableValue());
+ EncodableValue(details));
}
@@ void CloudFirestorePlugin::TransactionGet(
if (error_code != Error::kErrorOk) {
- result(FlutterError(error_message));
+ EncodableMap details;
+ details[EncodableValue("code")] = EncodableValue(GetErrorCode(error_code));
+ details[EncodableValue("message")] = EncodableValue(error_message);
+ result(FlutterError("firebase_firestore", error_message, details));
} else {
Reproducing the issue
On Windows, with rules that deny reading a document:
match /denied/{doc} { allow read: if false; }
try {
await FirebaseFirestore.instance.runTransaction((tx) async {
await tx.get(FirebaseFirestore.instance.doc('denied/doc'));
});
} on FirebaseException catch (e) {
print('${e.code}: ${e.message}');
}
- Expected:
permission-denied: Missing or insufficient permissions., as the same read outside a transaction reports. - Actual:
unknown:(empty message).
A transaction whose write is denied by rules shows the commit path: the code is unknown and the message is kept.
Firebase Core version
4.13.0 (cloud_firestore 6.8.0; the code is unchanged in 6.9.0 and on main at a646d55)
Flutter Version
3.47.4 (Dart 3.13.3)
Relevant Log Output
FirebaseException: [cloud_firestore/unknown]
_extractReplyValueOrThrow (messages.pigeon.dart:27)
FirebaseFirestoreHostApi.transactionGet (messages.pigeon.dart:1477)
MethodChannelTransaction.get (method_channel_transaction.dart:50)
Transaction.get (transaction.dart:28)
Flutter dependencies
cloud_firestore 6.8.0, cloud_firestore_platform_interface 8.0.6, _flutterfire_internals 1.3.76, firebase_core 4.13.0. Windows 11 (build 26200), release build.
Additional context and comments
Every other error path in the file builds details itself (ParseError, the bundle loader), so this looks like two call sites that were missed rather than a design choice.
- Ngôn ngữ chính
- Dart
- Star
- 9.3k
- Fork
- 4.1k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 82
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/flutterfire
-
[firebase_messaging]: Android ANR during background service destruction — main thread blocked in releaseWakeLockCó thể đã có người làm @SelaseKay đã nhận 5 ngày trước. Đang mởNeeds Attention platform: android plugin: messaging reproduced type: bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
firebase/flutterfire#18866 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blocked: customer-response Needs Attention platform: ios plugin: messaging Stale type: bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
firebase/flutterfire#18776 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[firebase_storage] Windows native crash in upload progress callback, sink ownership and thread dispatchCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởblocked: flutter platform: windows plugin: storage reproduced type: bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
firebase/flutterfire#18664 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[core] Decouple platform_interface from Flutter for pure-Dart webCó thể làm lại được @Lyokone đã nhận 41 ngày trước và không có pull request nào đang mở. Đang mởNeeds Attention platform: all platform: web plugin: core type: enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
firebase/flutterfire#18645 · 3 bình luận · 2 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blocked: firebase-sdk platform: android plugin: messaging reproduced type: bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
firebase/flutterfire#18644 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firebase/flutterfire
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ymm-oss/flutter-mobile-project-template#704 ·
Maintainer thường phản hồi trong vòng 15 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] MCP tools/list returns a boolean JSON Schema for get_task_stats, breaking strict clientsCó thể đã có người làm @monkeyWie đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] 下载路径文件夹中包含空格会导致保存路径错误Đang mởbug | 问题
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
FoxSensei001/LoveIwara#137 ·
-
[dwds] WebkitDebugger.enable 5-second hardcoded timeout causes TimeoutException on large web appsĐang mởpackage:dwds
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100