-
Notifications
You must be signed in to change notification settings - Fork 38
bug: potential runtime crashes from unwrap/expect usage #41
Copy link
Copy link
Open
Description
Files:
- apps/mofa-asr/src/screen/mod.rs,
- node-hub/dora-funasr-nano-mlx/src/main.rs
- mofa-dora-bridge/src/parser.rs
- node-hub/dora-gpt-sovits-mlx/src/ssml.rs
Several runtime and UI code paths rely on unwrap(), expect(), or other panic-based error handling. These constructs terminate execution when encountering unexpected Err or None values.
Current Behavior:
- Startup logic unwraps optional engine state, which may terminate execution if initialization fails.
- UI code uses
expect("... mutex poisoned"), causing additional panics if a mutex becomes poisoned after a prior failure. - Parser and SSML logic unwrap parsing results that may depend on external or user-provided input.
- Some tests use raw
unwrap()calls that produce less informative failures.
Expected Behavior:
- Runtime code should propagate errors using
Resultinstead of panicking. - Missing configuration or state should produce logged, recoverable errors.
- UI paths should recover safely from poisoned mutexes.
- Parsing failures should return structured errors rather than terminating execution.
Proposed Changes:
Current:
let engine = engine.as_mut().unwrap();Proposed:
let engine = match engine.as_mut() {
Some(e) => e,
None => {
log::error!("Engine unexpectedly missing after attempted initialization");
send_log(&mut node, "ERROR", "Engine not available")?;
continue;
}
};Current:
let mut guard = controller.lock().expect("ChatController mutex poisoned");Proposed:
let mut guard = match controller.lock() {
Ok(g) => g,
Err(poisoned) => {
log::warn!("ChatController mutex poisoned; recovering inner state");
poisoned.into_inner()
}
};Current:
let parsed = DataflowParser::parse_string(yaml, PathBuf::from("test.yml")).unwrap();Proposed:
let parsed = DataflowParser::parse_string(yaml, PathBuf::from("test.yml"))
.expect("DataflowParser failed to parse a valid test YAML; check parser changes");Current:
let result = parse_ssml("<speak>hello world</speak>").unwrap();Proposed:
let result = parse_ssml("<speak>hello world</speak>")
.expect("parse_ssml should parse simple <speak> content");Would like to work on a PR for this if the maintainers approve
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels