Skip to content

fix(db): return error instead of panicking on non-UTF-8 database path#2316

Open
Ollie202 wants to merge 1 commit into
0xMiden:nextfrom
Ollie202:fix/db-non-utf8-path
Open

fix(db): return error instead of panicking on non-UTF-8 database path#2316
Ollie202 wants to merge 1 commit into
0xMiden:nextfrom
Ollie202:fix/db-non-utf8-path

Conversation

@Ollie202

@Ollie202 Ollie202 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2289.

Db::new_with_pool_size called database_filepath.to_str().unwrap() at crates/db/src/lib.rs. On Linux, file paths can contain arbitrary (non-UTF-8) bytes, for which to_str() returns None, so unwrap() panics at node startup if the configured data path is non-UTF-8.

Change

  • Added a DatabaseError::NonUtf8Path(String) variant.
  • Replaced the unwrap() with an ok_or_else(...) that returns the new error, embedding the lossy path for context.

Testing

cargo build -p miden-node-db passes locally. The db crate is SQLite/diesel-based so it builds without the RocksDB toolchain.

Changelog

[[entry]]
scope       = "node"
impact      = "fixed"
description = "Return an error instead of panicking at startup when the database file path is not valid UTF-8."

@Ollie202 Ollie202 force-pushed the fix/db-non-utf8-path branch 2 times, most recently from b65b371 to 757ffa8 Compare July 6, 2026 20:35
`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.
@Ollie202 Ollie202 force-pushed the fix/db-non-utf8-path branch from 757ffa8 to da536a1 Compare July 7, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

db: to_str().unwrap() on database_filepath panics on non-UTF-8 paths

1 participant