Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file is not a database: , while compiling: select count(*) from sqlite_master; #906

Closed
yogeshpaliyal opened this issue Jun 28, 2024 · 15 comments · Fixed by #1077
Closed

Comments

@yogeshpaliyal
Copy link
Owner

Describe the bug
Error Stack

Exception android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
  at net.sqlcipher.database.SQLiteCompiledSql.native_compile (SQLiteCompiledSql.java)
  at net.sqlcipher.database.SQLiteCompiledSql.compile (SQLiteCompiledSql.java)
  at net.sqlcipher.database.SQLiteCompiledSql.<init> (SQLiteCompiledSql.java)
  at net.sqlcipher.database.SQLiteProgram.<init> (SQLiteProgram.java)
  at net.sqlcipher.database.SQLiteQuery.<init> (SQLiteQuery.java:2)
  at net.sqlcipher.database.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:2)
  at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java)
  at net.sqlcipher.database.SQLiteDatabase.rawQuery (SQLiteDatabase.java:2)
  at net.sqlcipher.database.SQLiteDatabase.keyDatabase (SQLiteDatabase.java)
  at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal (SQLiteDatabase.java:1)
  at net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:4)
  at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase (SQLiteDatabase.java:9)
  at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:2)
  at net.sqlcipher.database.SupportHelper.getWritableDatabase (SupportHelper.java:6)
  at androidx.room.RoomDatabase.inTransaction (RoomDatabase.kt:5)
  at androidx.room.RoomDatabase.assertNotSuspendingTransaction (RoomDatabase.kt:5)
  at com.yogeshpaliyal.common.db.DbDao_Impl.getAllAccountsAscending (DbDao_Impl.java:129)
  at com.yogeshpaliyal.keypass.ui.home.DashboardViewModel$queryUpdated$1.invokeSuspend (DashboardViewModel.kt:129)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:9)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:97)
  at kotlinx.coroutines.scheduling.TaskImpl.run (Tasks.kt:3)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.java:92)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:92)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:92)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:92)

We were not seeing this issue in v1.4.28 but getting in v1.4.29 and there is no changes releated to DB, sqlcipher, room, etc.

Here is the change logs from v1.4.28 → v1.4.29 1

Here is my SqlCipher file where I am initiating the DB. AppModule.kt

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@yogeshpaliyal yogeshpaliyal added the help wanted Extra attention is needed label Jun 28, 2024
@Layth17
Copy link

Layth17 commented Jan 30, 2025

Same issue here

@yogeshpaliyal
Copy link
Owner Author

@Layth17 thank you for commenting can you share more steps to reproduce maybe.

  1. Have you updated the app, if yes from which version to which.
  2. From where you've downloaded the app F-droid or Play Store.
  3. Have you recently updated your OS? Or rebooted the device.

Any other information that might be helpful to debug or reproduce this issue.

@Layth17
Copy link

Layth17 commented Feb 3, 2025

@Layth17 thank you for commenting can you share more steps to reproduce maybe.

  1. Have you updated the app, if yes from which version to which.
  2. From where you've downloaded the app F-droid or Play Store.
  3. Have you recently updated your OS? Or rebooted the device.

Any other information that might be helpful to debug or reproduce this issue.

Hello @yogeshpaliyal , sorry for the delay.

  1. yes, I had version 1.4.30 since 7/1/24 and updated to 1.4.34 as of 1/28/25
  2. F-droid
  3. Several times. I think I had an update this morning. I use GrapheneOS.

When I first updated the app, it was strange because it prompted me to enter a new password and confirm (as if it is creating a new account). I went along with it though I was hoping it would read the local database of passwords that I have at some point.

But afterwards, it prompted me to sign in, and it kept crashing whenever I would attempt to do so. The error log is identical to the above, but I can try to reproduce it in a moment and attach.

Do you happen to know where I could find the db of passwords locally on my phone? I have searched for it for quite some time but could not find anything.

@yogeshpaliyal
Copy link
Owner Author

What phone are you using? Is this slow, mid range or high end device?

@yogeshpaliyal
Copy link
Owner Author

Also approx how many passwords you were having on your device?

@Layth17
Copy link

Layth17 commented Feb 3, 2025

it is a google pixel 9.

hmm, it is hard to recall, but approx a little short of 20

@Layth17
Copy link

Layth17 commented Feb 3, 2025

type: crash
osVersion: google/tokay/tokay:15/AP4A.250105.002/2025020200:user/release-keys
flags: dev options enabled
package: com.yogeshpaliyal.keypass:1434, targetSdk 35
process: com.yogeshpaliyal.keypass
processUptime: 16554 + 238 ms
installer: org.fdroid.fdroid

android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
	at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
	at net.sqlcipher.database.SQLiteCompiledSql.compile(SourceFile:16)
	at net.sqlcipher.database.SQLiteCompiledSql.<init>(SourceFile:31)
	at net.sqlcipher.database.SQLiteProgram.<init>(SourceFile:106)
	at net.sqlcipher.database.SQLiteQuery.<init>(SourceFile:1)
	at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SourceFile:9)
	at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SourceFile:37)
	at net.sqlcipher.database.SQLiteDatabase.rawQuery(SourceFile:1)
	at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SourceFile:31)
	at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SourceFile:4)
	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SourceFile:10)
	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SourceFile:8)
	at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SourceFile:14)
	at net.sqlcipher.database.SupportHelper.getWritableDatabase(SourceFile:6)
	at j2.r.b(SourceFile:5)
	at B4.c.o(SourceFile:135)
	at Z4.a.j(SourceFile:9)
	at r5.F.run(SourceFile:113)
	at D2.a.run(SourceFile:100)
	at y5.i.run(SourceFile:3)
	at y5.a.run(SourceFile:92)
	Suppressed: w5.g: [p0{Cancelling}@62661b6, Dispatchers.IO]

@yogeshpaliyal
Copy link
Owner Author

Finally able to repro the crash, would fix this and would rollout a new version as soon as possible.

This happens if you have changed the password length from settings in older apps.

Trying to figure out the exact cause yet.

@Layth17 thanks a lot for the help 🙏🏼🙏🏼🙏🏼

@Layth17
Copy link

Layth17 commented Feb 3, 2025

I am not sure what this statement "This happens if you have changed the password length from settings in older apps." means. Did I change my password length without realizing?

Also, appreciate your support and time on this issue! Do ping me when the new version is out and I will be sure to test it! Thanks

@yogeshpaliyal
Copy link
Owner Author

Sure, Here is how you can replicate it

  1. Download v1.4.30 app.
  2. Set password go to app settings and change password length.
  3. Upgrade app to v1.4.34, you will see the screen to create password, once you set that app will crash.

@yogeshpaliyal
Copy link
Owner Author

Fixed in
v1.4.35

@yogeshpaliyal yogeshpaliyal removed the help wanted Extra attention is needed label Feb 3, 2025
@Layth17
Copy link

Layth17 commented Feb 3, 2025

I don't want to change the way I am managing the app since it could cause data loss. So, it seems that I would have to wait until F-droid makes the new version available.

@yogeshpaliyal
Copy link
Owner Author

I don't want to change the way I am managing the app since it could cause data loss. So, it seems that I would have to wait until F-droid makes the new version available.

Sorry, but you have to reinstall the app to work properly from new version onwards, because there is no way to fix the the crash, because when we updating from 1.4.30 to 1.4.34 the local storage password resets, so we are not able to open the database, even after 1.4.35 we will bot be able to recover the old password, i will think today if somehow we can retrieve the old password.

@Layth17
Copy link

Layth17 commented Feb 4, 2025

Forgive me if the question is silly, but I want to clarify:

Are you saying that: upon the update from 1.4.30 to 1.4.34, the local storage db of passwords has been reset to empty? (i.e. basically wiping the db of passwords clean?)

OR, are you saying that the very action of resetting the password has wiped the db clean?

OR, something else?

For the record, I do know the old password and I know my current password. As far as I understand, If I am able to locate the db locally on my phone, then I should be at least capable of backing it up and performing further investigations from there. But, I don't know how to find the db locally. Would you know where to find it?

Uninstalling the app (and installing the new version) sounds like the easiest way to get any shred of data that has remained locally gone forever :)

@yogeshpaliyal
Copy link
Owner Author

The problem is that the db password is random string generated if there is no db password.
Even if we get the db, we won't be able to get last db password.

Why db password and app password?
You can change the app password but you can't change db password(if you want it's complicated process)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants