{"record":{"id":"3c9fe66b14de785c","repo":"tursodatabase/turso","slug":"path-should-be-valid-string","errorCode":null,"errorMessage":"path should be valid string","messagePattern":"path should be valid string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/storage/journal_mode.rs","lineNumber":94,"sourceCode":"    // storage must also have an encryption context so the log is not plaintext\n    if let Some(storage) = &durable_storage {\n        if encryption_ctx.is_some() && storage.encryption_ctx().is_none() {\n            return Err(LimboError::InvalidArgument(\n                    \"encrypted MVCC requires the custom DurableStorage to be configured with encryption\"\n                        .to_string(),\n                ));\n        }\n    }\n    let storage: Arc<dyn mvcc::persistent_storage::DurableStorage> =\n        if let Some(storage) = durable_storage {\n            storage\n        } else {\n            let db_path = db_path.as_ref();\n            let log_path = db_path.with_extension(\"db-log\");\n            let string_path = log_path\n                .as_os_str()\n                .to_str()\n                .expect(\"path should be valid string\");\n            let file = io.open_file(string_path, flags, false)?;\n            Arc::new(mvcc::persistent_storage::Storage::new(\n                file,\n                io,\n                encryption_ctx,\n            ))\n        };\n\n    Ok(Arc::new(MvStore::new_in(\n        mvcc::MvccClock::new(),\n        storage,\n        allocator,\n        experimental_mvcc_passive_checkpoint,\n    )?))\n}\n","sourceCodeStart":76,"sourceCodeEnd":110,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/core/storage/journal_mode.rs#L76-L110","documentation":"open_mv_store() (core/storage/journal_mode.rs) derives the MVCC log path (db_path.with_extension(\"db-log\")) and converts it to &str with .expect(\"path should be valid string\") before io.open_file(). Rust paths are OsStr and not guaranteed UTF-8; any non-UTF-8 byte sequence in the path panics here.","triggerScenarios":"Opening or creating a database in experimental MVCC mode (journal_mode=mvcc) when the database path contains bytes that are not valid UTF-8 - the conversion log_path.as_os_str().to_str() returns None.","commonSituations":"Unix filesystems with arbitrary-byte filenames, temp directories with locale-odd names, PathBuf built from raw OS bytes, Windows paths with unpaired surrogates.","solutions":["Canonicalize or rename the database path to valid UTF-8 before opening in MVCC mode","Validate db_path.as_os_str().to_str() in your own code and return an error instead of letting the engine panic","Pass a custom DurableStorage via the durable_storage argument so the engine never stringifies the path itself","Track engine updates replacing to_str() with proper error handling"],"exampleFix":"// before\nlet db = Database::open(io, \"data\\u{fffd}\\u{fffd}.db\".as_path(), flags, mvcc_settings)?; // non-UTF-8 bytes panic in open_mv_store\n\n// after\nlet path = std::path::PathBuf::from(user_path);\nif path.as_os_str().to_str().is_none() {\n    return Err(format!(\"database path must be valid UTF-8 for MVCC: {path:?}\").into());\n}\nlet db = Database::open(io, path, flags, mvcc_settings)?;","handlingStrategy":"validation","validationCode":"// Validate before opening in MVCC mode:\nfn ensure_utf8_path(p: &std::path::Path) -> Result<&str, String> {\n    p.as_os_str().to_str().ok_or_else(|| format!(\"path is not valid UTF-8: {p:?}\"))\n}\nlet path_str = ensure_utf8_path(&db_path)?;\n// also check the derived log path turso will use:\nensure_utf8_path(&db_path.with_extension(\"db-log\"))?;","typeGuard":"fn is_valid_utf8_path(p: &std::path::Path) -> bool {\n    p.as_os_str().to_str().is_some()\n}","tryCatchPattern":null,"preventionTips":["Normalize database paths to UTF-8 early in your application (rename or canonicalize)","Remember MVCC derives a sibling .db-log path from the db path - both must be UTF-8","On Unix, avoid building PathBufs from arbitrary raw bytes when MVCC mode will be used","Provide a custom DurableStorage if you must support arbitrary OS paths"],"tags":["mvcc","file-path","utf-8","config","panic"],"backgroundTag":"non-utf8-file-path","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}