dani-garcia/vaultwarden · error

Error filtering events

Error message

Error filtering events

What it means

Panic from `.expect()` on the Diesel `load` in `Event::find_by_organization_uuid`. The paged query for an organization's events within a date range failed at the database level, aborting the request. The crate deliberately panics because a failed audit-log read is considered unrecoverable in that path.

Solutions

  1. Check DB connectivity and DATABASE_URL settings
  2. Apply pending migrations so the event table schema matches the code
  3. Inspect logs for the underlying Diesel error behind the panic
  4. Verify start/end parameters are valid datetime values accepted by the backend

Example fix

// before
.load::<Self>(conn).expect("Error filtering events")
// after
.load::<Self>(conn).unwrap_or_else(|e| { error!("event query failed: {e}"); Vec::new() })
Defensive patterns

Strategy: try-catch

Validate before calling

// validate date range before querying
if start > end { return Err("invalid date range"); }

Try / catch

// guard the request path
if !db_reachable().await { return fallback_empty_page(); }
Event::find_by_organization_uuid(org, start, end, &conn).await

Prevention

When it happens

Trigger: Calling `Event::find_by_organization_uuid` with an unreachable DB, missing/renamed `event` table columns, or a `between(start, end)` date comparison the driver rejects (e.g. type mismatch on event_date).

Common situations: Schema drift after upgrading without migrations; DB connection dropped mid-request; querying an org whose events table partition is missing; SQLite file locked by another process.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of dani-garcia/vaultwarden@cc67d644f6 (2026-09-19). Data as JSON: /api/errors/bb6b5f5936f846ef. Report an issue: GitHub.

Appendix: source

Thrown at src/db/models/event.rs:289

        .await
    }

    /// ##############
    /// Custom Queries
    pub async fn find_by_organization_uuid(
        org_uuid: &OrganizationId,
        start: &NaiveDateTime,
        end: &NaiveDateTime,
        conn: &DbConn,
    ) -> Vec<Self> {
        conn.run(move |conn| {
            event::table
                .filter(event::org_uuid.eq(org_uuid))
                .filter(event::event_date.between(start, end))
                .order_by(event::event_date.desc())
                .limit(Self::PAGE_SIZE)
                .load::<Self>(conn)
                .expect("Error filtering events")
        })
        .await
    }

    pub async fn count_by_org(org_uuid: &OrganizationId, conn: &DbConn) -> i64 {
        conn.run(move |conn| {
            event::table.filter(event::org_uuid.eq(org_uuid)).count().first::<i64>(conn).ok().unwrap_or(0)
        })
        .await
    }

    pub async fn find_by_org_and_member(
        org_uuid: &OrganizationId,
        member_uuid: &MembershipId,
        start: &NaiveDateTime,
        end: &NaiveDateTime,
        conn: &DbConn,
    ) -> Vec<Self> {

View on GitHub (pinned to cc67d644f6)