{"record":{"id":"aa30fba25e51f3ae","repo":"SeaQL/sea-orm","slug":"should-only-have-one-owner-aa30fb","errorCode":null,"errorMessage":"Should only have one owner","messagePattern":"Should only have one owner","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/database/sea_schema_shim.rs","lineNumber":92,"sourceCode":"\nfn map_result(result: Result<Vec<QueryResult>, DbErr>) -> Result<Vec<SqlxRow>, SqlxError> {\n    match result {\n        Ok(rows) => Ok(rows\n            .into_iter()\n            .filter_map(|r| match r.row {\n                #[cfg(feature = \"sqlx-mysql\")]\n                QueryResultRow::SqlxMySql(r) => Some(SqlxRow::MySql(r)),\n                #[cfg(feature = \"sqlx-postgres\")]\n                QueryResultRow::SqlxPostgres(r) => Some(SqlxRow::Postgres(r)),\n                #[cfg(feature = \"sqlx-sqlite\")]\n                QueryResultRow::SqlxSqlite(r) => Some(SqlxRow::Sqlite(r)),\n                #[allow(unreachable_patterns)]\n                _ => None,\n            })\n            .collect()),\n        Err(err) => Err(match err {\n            DbErr::Conn(RuntimeErr::SqlxError(err)) => {\n                Arc::into_inner(err).expect(\"Should only have one owner\")\n            }\n            DbErr::Exec(RuntimeErr::SqlxError(err)) => {\n                Arc::into_inner(err).expect(\"Should only have one owner\")\n            }\n            DbErr::Query(RuntimeErr::SqlxError(err)) => {\n                Arc::into_inner(err).expect(\"Should only have one owner\")\n            }\n            _ => SqlxError::AnyDriverError(Box::new(err)),\n        }),\n    }\n}\n","sourceCodeStart":74,"sourceCodeEnd":104,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/database/sea_schema_shim.rs#L74-L104","documentation":"In the sea_schema shim's `map_result`, when a query fails with a `DbErr` wrapping a `sqlx` error inside an `Arc`, the code calls `Arc::into_inner(err).expect(\"Should only have one owner\")` to unwrap the sqlx error. `Arc::into_inner` returns `None` if other clones of the Arc exist — the panic asserts the error is uniquely owned at that point.","triggerScenarios":"The same `DbErr::Conn/Exec/Query(RuntimeErr::SqlxError(...))` value was cloned before being returned from `query_all`/`query_all_raw`, so the Arc has refcount > 1 when mapped. Multi-threaded code sharing the error also triggers it.","commonSituations":"Application code storing or cloning the returned DbErr (e.g. logging wrappers, error aggregation) while also passing it into schema-inspection helpers; concurrent tasks sharing one error value.","solutions":["Drop/clone-free other references: ensure the DbErr is moved (not cloned) into the shim mapping path.","Avoid keeping clones of the error while calling sea_schema query helpers; clone the string representation instead.","If it recurs, restructure so each error is consumed once, e.g. map to your own error type at the boundary before passing along."],"exampleFix":"// before\nlet err_clone = err.clone();\nlog::error!(\"{}\", err_clone);\nschema_discovery::map_result(err); // Arc still shared -> panic\n// after\nlog::error!(\"{}\", err); // log first\nschema_discovery::map_result(err); // move uniquely-owned error","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// the panic comes from Arc::into_inner inside the library; guard by not cloning the error:\nlet outcome = discovery.query_all(...).await;\nmatch outcome {\n    Ok(rows) => { /* ... */ }\n    Err(e) => {\n        // consume e exactly once; log via formatted string, never clone the DbErr\n        return Err(MyError::from(e));\n    }\n}","preventionTips":["Move DbErr values instead of cloning them when handing them to schema helpers.","Convert library errors into your own error type at the API boundary.","Avoid sharing one DbErr across threads/tasks."],"tags":["panic","arc","ownership","sqlx","schema"],"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-14T11:17:12.474Z"}