PhilippC / PhilippC/keepass2android
[BUG] Unable to Sync Database stored on Google Drive
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 478
- Avg merge
- 1h 4m
- Merged PRs (30d)
- 2
Description
Checks
- I have read the FAQ section, searched the open issues, and still think this is a new bug.
Describe the bug you encountered:
Whenever you make a change to the local copy of the DB (e.g. add an entry) and save, the sync to the remote file on google drive fails, and only the local copy is updated with the change.
I've seen this bug crop up across multiple android devices (tablet and phone) when a KBDX file is stored/referenced on google drive.
Other Considerations of Note:
- This behaviour appears to present itself on as many versions of the app that have bee released in the last year and on both android 12 and 13.
- When tested, both devices that experience this problem had the Google Drive app installed.
- Both devices reference the same KDBX file
- Referencing a KBDX on google drive from a fresh app install, and then syncing appears to succeed, but subsequent closing and re-opening of the app results in sync failure.
Inspection of the log shows an exception on manual sync with a stack trace:
Important Note: I've obfuscated things, but its worth pointing out that this log entry did "leak" out my email address, google drive KBDX file name, and some other information. On a quick look, I am not sure if any of these are tokens or other important encoded values, so we should double check that too.
11/22/2023 11:12:08 PM:641 -- status message: Initializing...
11/22/2023 11:12:08 PM:642 -- status submessage:
11/22/2023 11:12:08 PM:660 -- status message: Synchronizing cached database…
11/22/2023 11:12:08 PM:661 -- status submessage: Loading source file…
11/22/2023 11:12:08 PM:889 -- status submessage: Restoring source file…
11/22/2023 11:12:08 PM:890 -- gdrive://.U8-john.doe%[40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F](http://40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F) localVersionHash = 831C1552BD14FC35D1BDD57BDC37022B2E4FF0B070E593B7A61FEBA4F7F0D32611/22/2023
11:12:09 PM:93 -- error getting file with for gdrive://.U8-john.doe%[40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F](http://40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F)
11/22/2023 11:12:09 PM:96 -- System.Exception: error getting file with for gdrive://.U8-john.doe%[40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F](http://40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F) ---> Java.IO.FileNotFoundException: error getting file with for gdrive://.U8-john.doe%[40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F](http://40gmail.com/.U8-kp-KP2A-1l0c8cfKdodmcmmdbSQellSAX-eIUuSu5/.U8-EXAMPLE-KEYPASS-DATABASE.kdbx-KP2A-10rny2SEiMSbLFMUpBQs9DTT6Iy0jwX5F) at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <6fb1725a77344b3e81b15cb69a959b5c>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00036] in <6fb1725a77344b3e81b15cb69a959b5c>:0 at Keepass2android.Javafilestorage.GoogleDriveBaseFileStorage.UploadFile (System.String path, System.Byte[] data, System.Boolean writeTransactional) [0x00059] in <ef4fc53bed604ca380e5f749cd276ee6>:0 at keepass2android.Io.JavaFileStorage+JavaFileStorageWriteTransaction.CommitWrite () [0x0001c] in <483bd1ecfe364ef6a0dfb2f58ee9f0f5>:0 --- End of inner exception stack trace --- at keepass2android.Io.JavaFileStorage+JavaFileStorageWriteTransaction.CommitWrite () [0x00036] in <483bd1ecfe364ef6a0dfb2f58ee9f0f5>:0 at keepass2android.Io.CachingFileStorage.UpdateRemoteFile (System.IO.Stream cachedData, KeePassLib.Serialization.IOConnectionInfo ioc, System.Boolean useFileTransaction, System.String hash) [0x00022] in <483bd1ecfe364ef6a0dfb2f58ee9f0f5>:0 at keepass2android.Io.CachingFileStorage.UpdateRemoteFile (KeePassLib.Serialization.IOConnectionInfo ioc, System.Boolean useFileTransaction) [0x00018] in <483bd1ecfe364ef6a0dfb2f58ee9f0f5>:0 at keepass2android.SynchronizeCachedDatabase.Run () [0x0009e] in <483bd1ecfe364ef6a0dfb2f58ee9f0f5>:0
Rampant Speculation:
- The URI path is URL encoded. Probably nothing, but I have see bugs before where an encoded URL gets saved/passed and causes unexpected behaviour
- "Error getting file with for gdrive" -> The path it logs looks funny. What is all the extra stuff appended? Is that a token-ized temporary path that is maybe no longer valid?
Not sure how busy contributors are - I don't have a dev env for this project set up - but if maintainers want help debugging or a PR, I am happy to do so, but it may take me some time as we have a new baby.
Thanks!
Describe what you expected to happen:
When attempting to reconcile/synchronise a remotely stored google drive KBDX file, it should succeed.
What version of Keepass2Android are you using?
1.09e-r7
Which version of Android are you on?
13
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at GoogleDriveBaseFileStorage.UploadFile and JavaFileStorageWriteTransaction.CommitWrite, then trace the gdrive URI handling described in the stack trace. Reproduce the failure after reopening a Google Drive KDBX file on Android 13 and inspect whether the logged path or persisted reference causes the error. Done means subsequent synchronization succeeds without exposing email addresses, file names, or other sensitive values in logs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp, google-cloud
- Domain
- cloud, mobile, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100