{"record":{"id":"695bd0cf0a9c8b5b","repo":"gitbutlerapp/gitbutler","slug":"panic-while-executing-panic-backtrace-un","errorCode":null,"errorMessage":"panic while executing `{}`: {}\n\npanic backtrace unavailable from hook; conversion backtrace:\n{}","messagePattern":"panic while executing `(.+?)`: (.+?)\n\npanic backtrace unavailable from hook; conversion backtrace:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/but-api/src/panic_capture.rs","lineNumber":76,"sourceCode":"            .payload_message\n            .as_deref()\n            .or(payload_message.as_deref())\n            .unwrap_or(\"panic payload was not a string\");\n        let panic_location = snapshot.location.as_deref().unwrap_or(\"<unknown location>\");\n        anyhow::anyhow!(\n            \"panic while executing `{}` on thread '{}' ({}) at {}: {}\\n\\npanic backtrace:\\n{}\",\n            function_name,\n            snapshot.thread_name,\n            snapshot.thread_id,\n            panic_location,\n            panic_message,\n            snapshot.backtrace\n        )\n    } else {\n        let panic_message = payload_message\n            .as_deref()\n            .unwrap_or(\"panic payload was not a string\");\n        anyhow::anyhow!(\n            \"panic while executing `{}`: {}\\n\\npanic backtrace unavailable from hook; conversion backtrace:\\n{}\",\n            function_name,\n            panic_message,\n            std::backtrace::Backtrace::force_capture()\n        )\n    }\n}\n\n/// Installs a hook that captures panic context and then delegates to the previous hook.\n/// Can be called multiple times, but only the first call will install the hook.\npub fn install_panic_hook() {\n    INSTALL_PANIC_HOOK.call_once(|| {\n        let previous_hook = panic::take_hook();\n        panic::set_hook(Box::new(move |panic_info| {\n            capture_panic_info(panic_info);\n            previous_hook(panic_info);\n        }));\n    });","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/panic_capture.rs#L58-L94","documentation":"Variant of panic conversion in `panic_payload_to_anyhow` used when no backtrace snapshot is available (the hook could not provide one). It reports the panicking function and panic message, notes that the backtrace is unavailable, and instead attaches a backtrace captured at conversion time.","triggerScenarios":"A wrapped function panics but the panic hook's snapshot lacks a backtrace (e.g. hook installed without backtrace capture, or payload arrives outside the hook's recording window).","commonSituations":"Panics in threads or contexts where the custom hook did not run or could not snapshot; RUST_BACKTRACE unset at hook setup; panic payload is a non-string value.","solutions":["Inspect the function name and panic message to locate the bug","Fix the panicking unwrap/assert in the named function","Set RUST_BACKTRACE=1 and ensure the panic hook is installed early so snapshots include backtraces","Use the conversion backtrace in the message to see the call path into the panicking code"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// handle panic-converted errors without a backtrace snapshot\nif let Err(e) = wrapped_call() {\n    let msg = format!(\"{e:#}\");\n    if msg.contains(\"panic backtrace unavailable\") {\n        eprintln!(\"panic in {}: {}\", fn_name, msg);\n    }\n    return Err(e.into());\n}","preventionTips":["Install the panic-capture hook before spawning threads","Ensure RUST_BACKTRACE is enabled when configuring the hook","Panic with string payloads so messages are readable"],"tags":["panic","rust","backtrace"],"backgroundTag":"internal-invariant-violation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}