fix(db): return error instead of panicking on non-UTF-8 database path#2316
Open
Ollie202 wants to merge 1 commit into
Open
fix(db): return error instead of panicking on non-UTF-8 database path#2316Ollie202 wants to merge 1 commit into
Ollie202 wants to merge 1 commit into
Conversation
b65b371 to
757ffa8
Compare
`Db::new_with_pool_size` called `database_filepath.to_str().unwrap()`, which panics at node startup if the data path contains non-UTF-8 bytes (possible on Linux). Convert the failure into a new `DatabaseError::NonUtf8Path` instead. Closes 0xMiden#2289.
757ffa8 to
da536a1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2289.
Db::new_with_pool_sizecalleddatabase_filepath.to_str().unwrap()atcrates/db/src/lib.rs. On Linux, file paths can contain arbitrary (non-UTF-8) bytes, for whichto_str()returnsNone, sounwrap()panics at node startup if the configured data path is non-UTF-8.Change
DatabaseError::NonUtf8Path(String)variant.unwrap()with anok_or_else(...)that returns the new error, embedding the lossy path for context.Testing
cargo build -p miden-node-dbpasses locally. Thedbcrate is SQLite/diesel-based so it builds without the RocksDB toolchain.Changelog