0xMiden / 0xMiden/note-transport-service

Fail-open database creation silently starts an empty DB

Open
#124 0 comments 0 reactions 0 assignees View on GitHub
bug production-readiness
Dominant language
Rust
Stars
3
Forks
10
Avg merge
2h 23m
Merged PRs (30d)
4

Description

Severity: high.

### Summary

`connect()` calls `std::fs::File::create(&config.url)` whenever the path does not exist (`crates/node/src/database/sqlite/mod.rs:86-90`). Combined with `seq INTEGER PRIMARY KEY AUTOINCREMENT`, a fresh file restarts the sequence at 1.

### Impact

Any wrong `--database-url`, unmounted Docker volume, or deleted file yields a brand-new empty database with a regressed sequence space — silently, with migrations auto-running and no loud log. This is a distinct trigger for the #101 dead band from the `:memory:` default (#112): it bites even with a correct-*looking* file URL. Clients holding a persisted cursor above the new high-water fetch zero notes for the skipped range, permanently.

### Recommendation

- Fail startup if the file does not exist unless an explicit `--create-database` (or first-run) flag is passed.
- Persist a DB instance/epoch identifier and expose it (e.g. in `FetchNotesResponse`) so clients can detect a sequence-space reset and restart from 0 — this is the client-side recovery path #101 calls for.

Related: #101, #112.

---
Part of #114.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.