Desktop RTDB: Repo::HandleTransactionResponse collapses every non-datastale server error (incl. permission_denied) to kErrorUnknownError with an empty message
还没有人认领这个 Issue。
评估
调研方向
从 database/src/desktop/core/repo.cc 中的 Repo::HandleTransactionResponse() 和 RerunTransactionQueue() 开始,然后比较 database/src/desktop/connection/persistent_connection.cc 中响应状态和消息的流转。完成的标准是事务失败会保留映射后的服务器错误代码和消息,包括 permission_denied,而不是以 kErrorUnknownError 和空消息完成。
由索引模型根据 Issue 内容生成。
描述
Environment
- Firebase C++ SDK 13.9.0 (desktop/Windows; the cited code is unchanged at the 13.11.0 tag)
- Identified while tracing FlutterFire
firebase_database12.4.6 on Windows; the defect below is independently confirmed from the pinned desktop C++ source.
What happens
When the server rejects a transaction commit (e.g. a security-rules fence returns permission_denied on the wire), the transaction Future<DataSnapshot> completes with:
error()=kErrorUnknownError(10) — notkErrorPermissionDenied(8)error_message()=""(empty)
so callers cannot distinguish "rules denied this commit" from any other failure, and there is no message to log. Plain SetValue() writes on the same path correctly surface kErrorPermissionDenied, which makes the transaction behavior surprising.
Where the information is lost (pinned to 3d7ce2a, the 13.9.0 tag)
- The wire layer maps the response status correctly and retains the server message.
HandlePutResponse()converts the status and passes the response body toTriggerResponse():
https://github.com/firebase/firebase-cpp-sdk/blob/3d7ce2a584d0b8daf1374bc2534c6ea71fa7fd6c/database/src/desktop/connection/persistent_connection.cc#L955-L970
TriggerResponse()stores both values, and the adjacent status map includespermission_denied→kErrorPermissionDenied:
https://github.com/firebase/firebase-cpp-sdk/blob/3d7ce2a584d0b8daf1374bc2534c6ea71fa7fd6c/database/src/desktop/connection/persistent_connection.cc#L1244-L1281 Repo::HandleTransactionResponse()then discards both fields for every error response other thandatastale:
https://github.com/firebase/firebase-cpp-sdk/blob/3d7ce2a584d0b8daf1374bc2534c6ea71fa7fd6c/database/src/desktop/core/repo.cc#L982-L1000for (auto& transaction : response->queue()) { transaction->status = TransactionData::kStatusNeedsAbort; transaction->abort_reason = kErrorUnknownError; }RerunTransactionQueue()finally completes the future with the no-message overload, soerror_message()is empty:
https://github.com/firebase/firebase-cpp-sdk/blob/3d7ce2a584d0b8daf1374bc2534c6ea71fa7fd6c/database/src/desktop/core/repo.cc#L1003-L1138DataSnapshot snapshot(new DataSnapshotInternal( database_, node, QuerySpec(transaction->path))); transaction->ref_future->CompleteWithResult(transaction->future_handle, abort_reason, snapshot);
Expected
abort_reason should carry the mapped response code (8 for permission_denied, etc.) and the completion should pass the response's error message through, matching what the Android SDK reports for the same server rejection.
Impact
Any desktop app implementing fenced/optimistic transactions (rules-enforced epochs, leases, counters) receives an undiagnosable unknown/empty failure for what is actually a well-defined rules denial. Downstream SDK wrappers (e.g. FlutterFire's Windows plugin) inherit the collapsed code, so the loss is user-visible in every binding built on this implementation.
- 主要语言
- C++
- 星标
- 326
- 派生
- 138
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-cpp-sdk 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
firebase/firebase-cpp-sdk#1905 · 2 条评论 ·
-
api: firestore
难度 5/5 一周以上 新手友好度 35/100
firebase/firebase-cpp-sdk#1920 · 3 条评论 ·
-
new type: question
难度 4/5 3-5 天 新手友好度 45/100
firebase/firebase-cpp-sdk#1892 · 1 条评论 ·
-
nightly-testing
难度 4/5 3-5 天 新手友好度 25/100
firebase/firebase-cpp-sdk#1859 ·
-
nightly-testing
难度 4/5 3-5 天 新手友好度 30/100
firebase/firebase-cpp-sdk#1858 ·
查看 firebase/firebase-cpp-sdk 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Component: GLib
难度 2/5 1-3 小时 新手友好度 70/100
-
Mute ydb/tests/functional/dstool/test_canonical_requests.py.Test.test_group_take_snapshot in main 未关闭ai_reviewed
难度 2/5 1-3 小时 新手友好度 70/100
ydb-platform/ydb#53974 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google/libultrahdr#485 ·