dani-garcia/vaultwarden · error
Error loading org_policy
Error message
Error loading org_policy
What it means
Panic raised in OrgPolicy::find_by_org: the query loading all org_policies rows filtered by org_uuid is unwrapped with .expect(). An organization with no policies returns an empty vec and does not trigger this; the panic fires only when the SQL fails - a dead connection, missing/mismatched org_policies schema, or a row that fails to deserialize into the OrgPolicy model.
Solutions
- Verify database availability and connection pool health
- Confirm the org_policies table schema matches the OrgPolicy model via migrations
- Capture the diesel error from the panic message to diagnose the exact SQL problem
- Replace .expect with .map_res so the caller receives an ApiError rather than a panic
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/db/models/org_policy.rs:169 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dani-garcia/vaultwarden@cc67d644f6 (2026-09-19).
Data as JSON: /api/errors/00c07fdb81183f6a.
Report an issue: GitHub.
Appendix: source
Thrown at src/db/models/org_policy.rs:169
}
}
}
pub async fn delete(self, conn: &DbConn) -> EmptyResult {
conn.run(move |conn| {
diesel::delete(org_policies::table.filter(org_policies::uuid.eq(self.uuid)))
.execute(conn)
.map_res("Error deleting org_policy")
})
.await
}
pub async fn find_by_org(org_uuid: &OrganizationId, conn: &DbConn) -> Vec<Self> {
conn.run(move |conn| {
org_policies::table
.filter(org_policies::org_uuid.eq(org_uuid))
.load::<Self>(conn)
.expect("Error loading org_policy")
})
.await
}
pub async fn find_confirmed_by_user(user_uuid: &UserId, conn: &DbConn) -> Vec<Self> {
conn.run(move |conn| {
org_policies::table
.inner_join(
users_organizations::table.on(users_organizations::org_uuid
.eq(org_policies::org_uuid)
.and(users_organizations::user_uuid.eq(user_uuid))),
)
.filter(users_organizations::status.eq(MembershipStatus::Confirmed as i32))
.select(org_policies::all_columns)
.load::<Self>(conn)
.expect("Error loading org_policy")
})
.awaitView on GitHub (pinned to cc67d644f6)