{"record":{"id":"fde302cf04c980f3","repo":"dbt-labs/dbt-core","slug":"e-fde302","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-runtime/src/handle.rs","lineNumber":101,"sourceCode":"        }\n    }\n\n    /// Returns the handle set for the current thread.\n    ///\n    /// # Panics\n    ///\n    /// Panics if called outside a [`Handle::enter`] scope. In particular this\n    /// panics inside a blocking task, by design — see the module docs. For a\n    /// non-panicking version see [`Handle::try_current`].\n    #[track_caller]\n    pub fn current() -> Handle {\n        match Handle::try_current() {\n            Ok(handle) => handle,\n            Err(e) => {\n                if cfg!(debug_assertions) {\n                    panic!(\"{e}\\n{:?}\", std::backtrace::Backtrace::force_capture());\n                } else {\n                    panic!(\"{e}\");\n                }\n            }\n        }\n    }\n\n    /// Returns the handle set for the current thread, if any.\n    pub fn try_current() -> Result<Handle, TryCurrentError> {\n        current::with_current(Handle::clone)\n    }\n\n    /// Sets this handle as the current one until the returned guard is dropped.\n    pub fn enter(&self) -> EnterGuard<'_> {\n        EnterGuard {\n            _guard: current::try_set_current(self)\n                .expect(\"cannot enter a runtime handle while the thread is shutting down\"),\n            _handle_lifetime: PhantomData,\n        }\n    }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-runtime/src/handle.rs#L83-L119","documentation":"This is the release-build panic path of the same Handle::current() call: when try_current() reports no runtime handle for the current thread, the code panics with the underlying error message (without the backtrace that debug builds add). It signals that a runtime-context-dependent API was reached from a thread that is not part of any runtime.","triggerScenarios":"Invoking Handle::current() outside any runtime context — from a plain OS thread, from main() before the runtime is built, after runtime shutdown, or from blocking sections that left the runtime scope — in a release build (no debug_assertions).","commonSituations":"Mixing std::thread::spawn with runtime handles; libraries calling Handle::current() in Drop impls or destructors that may run on arbitrary threads; production (release) builds surfacing the same bug previously seen with backtrace in debug builds.","solutions":["Switch to Handle::try_current() and handle the no-runtime case gracefully.","Enter the runtime on foreign threads before calling runtime APIs (`handle.enter()` guard).","Thread the Handle through function parameters or an app-level context instead of thread-locals.","Reproduce with a debug build to get the backtrace identifying the off-runtime call site."],"exampleFix":"// before\nfn notify() {\n    let h = Handle::current();\n    h.spawn(async { ... });\n}\n\n// after\nfn notify(handle: Option<Handle>) {\n    if let Some(h) = handle.or_else(|| Handle::try_current().ok()) {\n        h.spawn(async { ... });\n    }\n}","handlingStrategy":"try-catch","validationCode":"// production build has no backtrace; reproduce with debug asserts\ncargo run --debug  # or check cfg!(debug_assertions) to get the backtrace variant","typeGuard":"fn runtime_available() -> bool {\n    Handle::try_current().is_ok()\n}","tryCatchPattern":"match Handle::try_current() {\n    Ok(h) => h,\n    Err(e) => {\n        log::error!(\"Handle::current called off-runtime: {e}\");\n        std::process::exit(1); // or use a stored Handle\n    }\n}","preventionTips":["Call Handle::current() only from within runtime threads or an active handle.enter() scope.","Keep a globally stored Handle (set once after runtime startup) for code on arbitrary threads.","Avoid calling runtime APIs in Drop impls that may run after runtime shutdown.","Run debug builds during development to get backtraces pinpointing off-runtime call sites."],"tags":["rust","runtime","panic","async","tokio"],"backgroundTag":"internal-invariant-violation","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}