{"record":{"id":"575c9113710d671d","repo":"SeaQL/sea-orm","slug":"should-only-have-one-owner","errorCode":null,"errorMessage":"Should only have one owner","messagePattern":"Should only have one owner","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/database/sea_schema_rusqlite.rs","lineNumber":50,"sourceCode":"    }\n}\n\nfn map_result(result: Result<Vec<QueryResult>, DbErr>) -> Result<Vec<RusqliteRow>, RusqliteError> {\n    match result {\n        Ok(rows) => Ok(rows\n            .into_iter()\n            .filter_map(|r| match r.row {\n                #[cfg(feature = \"rusqlite\")]\n                QueryResultRow::Rusqlite(OurRusqliteRow { values, .. }) => {\n                    Some(RusqliteRow { values })\n                }\n                #[allow(unreachable_patterns)]\n                _ => None,\n            })\n            .collect()),\n        Err(err) => Err(match err {\n            DbErr::Conn(RuntimeErr::Rusqlite(err)) => {\n                Arc::into_inner(err).expect(\"Should only have one owner\")\n            }\n            DbErr::Exec(RuntimeErr::Rusqlite(err)) => {\n                Arc::into_inner(err).expect(\"Should only have one owner\")\n            }\n            DbErr::Query(RuntimeErr::Rusqlite(err)) => {\n                Arc::into_inner(err).expect(\"Should only have one owner\")\n            }\n            _ => RusqliteError::InvalidParameterName(err.to_string()),\n        }),\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":62,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/database/sea_schema_rusqlite.rs#L32-L62","documentation":"This panic comes from `Arc::into_inner(err).expect(\"Should only have one owner\")` in the rusqlite error-mapping shim that adapts `DbErr` results for sea_schema's `Connection` trait. `Arc::into_inner` returns `None` when the inner rusqlite error is still referenced by another clone of the `Arc`, so the library treats that as an impossible invariant break and panics. It means an internal error object was shared (cloned) somewhere it was assumed to be uniquely owned while converting a connection/exec/query failure into a `RusqliteError`.","triggerScenarios":"A `query_all` or `query_all_raw` call through the `sea_schema::Connection` impl for `DatabaseConnection`/`DatabaseTransaction` fails with `DbErr::Conn/RuntimeErr::Rusqlite` (or Exec/Query variants), and the wrapped `Arc<rusqlite::Error>` has refcount > 1 at the moment `map_result` unwraps it — i.e. the error was cloned before mapping.","commonSituations":"Hitting this usually indicates a library-level bug or an unusual error path (e.g. a SQLite error surfaced through a code path that clones the error into logs, pooled-connection wrappers, or multi-threaded sharing), rather than a user configuration mistake. It appears when using sea_schema discovery (schema introspection) over a rusqlite-backed sea-orm connection whose query fails.","solutions":["Check the sea-orm / sea-schema versions for a known fix and upgrade both crates to matching latest releases.","Avoid wrapping the connection in custom pooling or error-cloning layers that hold extra `Arc` references to `RuntimeErr::Rusqlite` errors.","Reproduce with a minimal failing query; if refcount sharing is caused by your middleware, capture error info via `err.to_string()` before it enters the shim.","Report the issue with the failing SQL and backtrace, since the `expect` documents an invariant the maintainers assume always holds."],"exampleFix":"// before (library side, panics if Arc is shared)\nDbErr::Conn(RuntimeErr::Rusqlite(err)) => {\n    Arc::into_inner(err).expect(\"Should only have one owner\")\n}\n// after (defensive: fall back to a synthesized error instead of panicking)\nDbErr::Conn(RuntimeErr::Rusqlite(err)) => {\n    Arc::try_unwrap(err).unwrap_or_else(|e| RusqliteError::InvalidParameterName(e.to_string()))\n}","handlingStrategy":"try-catch","validationCode":"// Panics cannot be caught by Result validation; use catch_unwind around discovery calls\nlet result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    sea_schema_discovery_query_all(&conn)\n}));","typeGuard":"fn is_unique_arc_err(err: &DbErr) -> bool {\n    match err {\n        DbErr::Conn(RuntimeErr::Rusqlite(e))\n        | DbErr::Exec(RuntimeErr::Rusqlite(e))\n        | DbErr::Query(RuntimeErr::Rusqlite(e)) => Arc::strong_count(e) == 1,\n        _ => false,\n    }\n}","tryCatchPattern":"let outcome = std::panic::catch_unwind(AssertUnwindSafe(|| {\n    schema.query_all(select)\n}));\nmatch outcome {\n    Ok(Ok(rows)) => use_rows(rows),\n    Ok(Err(e)) => handle_rusqlite_error(e),\n    Err(_) => log::error!(\"Arc ownership panic in sea_schema shim; failing over\"),\n}","preventionTips":["Keep sea-orm and sea-schema versions aligned and current","Do not clone DbErr values (or wrap connections in error-retaining middleware) around introspection calls","Run schema discovery inside catch_unwind if the process must survive library panics","Report any occurrence upstream — this expect is documented as unreachable"],"tags":["panic","arc","rusqlite","internal","error-mapping"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}