eventcore-sqlite: encrypted SqliteEventStore::migrate() fails on fresh DB with 'file is not a database' #324
Labels
No labels
adr
automated
bug
chore
dependencies
documentation
enhancement
epic
github-actions
P1-high
P2-medium
P3-low
release
research
rust
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jwilger/eventcore#324
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Using
eventcore-sqlite0.6.0 withSqliteConfig { encryption_key: Some(...) }fails on a fresh database file whenSqliteEventStore::new(...)is followed bymigrate().await.The failure is:
Minimal reproduction
Expected
migrate()should create and initialize the encrypted SQLite database successfully.Actual
migrate()fails withfile is not a database.Likely cause
This looks like a connection setup ordering problem in
eventcore-sqlite.In
src/lib.rs,open_connection()setsjournal_mode = WALbefore the encryption key is applied, and the key is only applied later inSqliteEventStore::new().That means the adapter touches the database before
PRAGMA keyhas been set. My inference is that this is enough to create or interact with the file as an unkeyed database, after which later SQLCipher operations fail.Workaround
A local workaround that unblocked me was:
PRAGMA keySELECT count(*) FROM sqlite_masterjournal_mode = WALContext
I hit this while implementing an encrypted operator-side licensing store that uses
eventcorecommand execution with SQLCipher-backed SQLite. I had to replace the SQLite shell adapter locally to keep usingeventcoresemantics with encrypted persistence.Completed in #333 — reordered PRAGMA key before WAL mode in SQLite encrypted stores.