fix(database,windows): fix transaction threwing and native error codes dropped - #18559
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
…s gaps `platformExceptionToFirebaseException` now lower-cases and dashes a code it takes from `PlatformException.code`, the same normalisation the auth converter applies to that field, so a native `UNKNOWN` keeps reporting as `unknown`. Skips three tests on Windows for pre-existing plugin gaps that the new e2e job exposed, unrelated to this PR: `startAfter` and `endBefore` are mapped onto the C++ SDK's inclusive `StartAt`/`EndAt` (it has no exclusive cursor), and the desktop SDK does not resolve `ServerValue.increment` sentinels. Also wraps a test name that pushed a line past the formatter's limit.
b133e41 to
63b82d3
Compare
Description
Fixes two
firebase_databasebugs on Windows.Transaction aborts threw instead of resolving with
committed: false. The desktop C++ SDK never emitskErrorTransactionAbortedByUser, so the plugin's benign branch was dead code there. It reports a deliberate abort askErrorWriteCanceledon the handler's initial invocation, and (becauseError error = kErrorNoneis declared and never assigned) askErrorNoneon a rerun, which the plugin reported ascommitted: true. Neither code can be trusted alone:kErrorWriteCanceledalso means "cancelled byPurgeOutstandingWrites()" and must stay an error. The transaction context now records the Dart handler's own decision and the data it saw, and the completion handler keys the contract off that.Native error codes were dropped, so every failure surfaced as
unknown.ParseError()and both listenerOnCancelledpaths used the two-argumentFlutterError/EventSink::Erroroverloads, which send null Pigeondetails, and the shared converter read the code only fromdetails. Now the Windows plugin sends adetailsmap keyedcode/message(as Android does), andplatformExceptionToFirebaseExceptionfalls back toPlatformException.codewhen there is nodetailspayload, which also recovers codes forfirebase_storageandfirebase_remote_configon Windows.The new
set()test showed Android and Apple lose the code on plain writes too, so those paths now route through the helpers each plugin already had. Windows also gets an e2e job (the suite never ran there) and the example'swindows/runner. Two Windows-only spellings are aligned with the other platforms:operation-failedtofailure,write-canceledtowrite-cancelled. Nothing could depend on them, since no Windows code reached Dart before.The transaction-based
permission-deniedtest expectsunknownon Windows only: the desktop SDK replaces non-datastaleserver errors on sent transactions withkErrorUnknownErrorbefore the plugin sees them (firebase-cpp-sdk#1904). Plain writes are unaffected.Related Issues
Transaction.abort()throwsFirebaseExceptioninstead of returningTransactionResult(committed: false)#18549Checklist
///).melos run analyze) does not report any problems on my PR.Breaking Change