SeaQL/sea-orm · info

Infallible

Error message

Infallible

What it means

This `.expect("Infallible")` panics if `write!` to a String fails, which is impossible for the in-memory fmt::Write used here — it is an assertion of an internal invariant while building the `SET search_path = ...` statement in connect(). In practice it should never fire; seeing it means an unexpected formatting/capacity failure, so it signals a library bug rather than user error.

Source

Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:101

            }
        }

        if let Some(application_name) = &options.application_name {
            sqlx_opts = sqlx_opts.application_name(application_name);
        }

        if let Some(timeout) = options.statement_timeout {
            sqlx_opts = sqlx_opts.options([("statement_timeout", timeout.as_millis().to_string())]);
        }

        if let Some(f) = &options.pg_opts_fn {
            sqlx_opts = f(sqlx_opts);
        }

        let set_search_path_sql = options.schema_search_path.as_ref().map(|schema| {
            let mut string = "SET search_path = ".to_owned();
            if schema.starts_with('"') {
                write!(&mut string, "{schema}").expect("Infallible");
            } else {
                for (i, schema) in schema.split(',').enumerate() {
                    if i > 0 {
                        write!(&mut string, ",").expect("Infallible");
                    }
                    if schema.starts_with('"') {
                        write!(&mut string, "{schema}").expect("Infallible");
                    } else {
                        write!(&mut string, "\"{schema}\"").expect("Infallible");
                    }
                }
            }
            string
        });

        let lazy = options.connect_lazy;
        let after_connect = options.after_connect.clone();
        let pg_pool_opts_fn = options.pg_pool_opts_fn.clone();

View on GitHub (pinned to e29bcd1b41)

Solutions

  1. Nothing actionable — this panic indicates a library-internal invariant break; file an issue with your schema_search_path value and versions.
  2. As a workaround, pass a quoted schema (wrapped in double quotes) or avoid schema_search_path and set the search path manually after connecting.
Defensive patterns

Strategy: try-catch

Try / catch

// The panic is unreachable; wrap connect() anyway if you must contain it:
let conn = std::panic::catch_unwind(|| Database::connect(opts.clone()))
    .map_err(|_| DbErr::Custom("connect panicked building search_path"))?

Prevention

When it happens

Trigger: Reached only if the `write!(&mut string, ...)` into the owned String in the schema_search_path handling of connect() somehow returns Err — theoretically impossible for String's fmt::Write impl; effectively unreachable.

Common situations: Practically never encountered by users; if observed it points to a patched toolchain, custom allocator/oom behavior during string growth, or a modified build of the driver code.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10). Data as JSON: /api/errors/1f9a92e7ad39eb28. Report an issue: GitHub.