{"record":{"id":"27cb73f292bbdb90","repo":"wasmerio/wasmer","slug":"not-implemented","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":"panic","httpStatus":null,"severity":"critical","filePath":"lib/vm/src/trap/trap.rs","lineNumber":80,"sourceCode":"    /// Internally saves a backtrace when constructed.\n    pub fn user(err: Box<dyn Error + Send + Sync>) -> Self {\n        Self::User(err)\n    }\n\n    /// Construct a new Wasm trap with the given source location and backtrace.\n    ///\n    /// Internally saves a backtrace when constructed.\n    pub fn wasm(pc: usize, backtrace: Backtrace, signal_trap: Option<TrapCode>) -> Self {\n        Self::Wasm {\n            pc,\n            backtrace,\n            signal_trap,\n        }\n    }\n\n    /// Returns trap code, if it's a Trap\n    pub fn to_trap(self) -> Option<TrapCode> {\n        unimplemented!()\n    }\n\n    /// Construct a new Wasm trap with the given trap code.\n    ///\n    /// Internally saves a backtrace when constructed.\n    pub fn lib(trap_code: TrapCode) -> Self {\n        let backtrace = Backtrace::new_unresolved();\n        Self::Lib {\n            trap_code,\n            backtrace,\n        }\n    }\n\n    /// Construct a new OOM trap with the given source location and trap code.\n    ///\n    /// Internally saves a backtrace when constructed.\n    pub fn oom() -> Self {\n        let backtrace = Backtrace::new_unresolved();","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/vm/src/trap/trap.rs#L62-L98","documentation":"Trap::to_trap is a stub: its body is a bare unimplemented!(), so calling it panics with \"not implemented\" every time. The method is documented to return Option<TrapCode> if the Trap carries a trap code, but that logic was never written. Any caller relying on it to classify a trap hits an unconditional panic, independent of the Trap variant (signal_trap, lib, etc.).","triggerScenarios":"Any call to Trap::to_trap() — e.g. code converting a raised Trap into a TrapCode when handling a wasm fault — panics immediately regardless of input.","commonSituations":"Embedder code classifying runtime faults (e.g. turning SIGSEGV-derived traps into TrapCode::MemoryOutOfBounds), custom host integrations, or ported code from wasmer versions where to_trap was implemented.","solutions":["Do not call to_trap; inspect the Trap variant directly and map signal-based traps to TrapCode yourself.","Implement to_trap locally: match the internal enum (e.g. Trap::Lib { trap_code, .. } => Some(trap_code), _ => None).","Use the library's existing trap-code accessor/APIs (e.g. Trap::lib / downcast helpers) instead.","File/patch upstream: the method body is an unfinished stub."],"exampleFix":"// before\nlet code = trap.to_trap(); // panics: unimplemented!()\n\n// after (local helper)\nfn trap_code_of(trap: &Trap) -> Option<TrapCode> {\n    match trap {\n        Trap::Lib { trap_code, .. } => Some(*trap_code),\n        _ => None,\n    }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// narrow Trap variants yourself instead of calling to_trap()\nfn trap_code_of(trap: &Trap) -> Option<TrapCode> {\n    match trap {\n        Trap::Lib { trap_code, .. } => Some(*trap_code),\n        _ => None,\n    }\n}","tryCatchPattern":"let code = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| trap.to_trap()))\n    .ok()\n    .flatten()\n    .or_else(|| trap_code_of(&trap));","preventionTips":["Never call stub methods marked unimplemented!; inspect the enum directly","Grep the dependency for unimplemented! before adopting an API","Write unit tests exercising trap classification so stubs fail fast in CI"],"tags":["rust","unimplemented","trap","stub"],"backgroundTag":"unimplemented-api-stub","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}