SeaQL/sea-orm · info
Infallible
Error message
Infallible
What it means
This panic comes from `.expect("Infallible")` on a `write!` into an in-memory `String` inside `Identity:: Many` rendering in `src/entity/identity.rs:79`. Writing to a `String` via `fmt::Write` cannot fail (allocation failure aborts instead), so the panic is a defensive assertion on an infallible operation. It is effectively unreachable in normal use; if it ever fires, memory is exhausted or the `Display` impl of an identifier misbehaves.
Source
Thrown at src/entity/identity.rs:79
fn into_iter(self) -> Self::IntoIter {
OwnedIdentityIter {
identity: self,
index: 0,
}
}
}
impl Iden for Identity {
fn quoted(&self) -> Cow<'static, str> {
match self {
Identity::Unary(iden) => iden.inner(),
Identity::Binary(iden1, iden2) => Cow::Owned(format!("{iden1}{iden2}")),
Identity::Ternary(iden1, iden2, iden3) => Cow::Owned(format!("{iden1}{iden2}{iden3}")),
Identity::Many(vec) => {
let mut s = String::new();
for iden in vec.iter() {
write!(&mut s, "{iden}").expect("Infallible");
}
Cow::Owned(s)
}
}
}
fn to_string(&self) -> String {
match self.quoted() {
Cow::Borrowed(s) => s.to_owned(),
Cow::Owned(s) => s,
}
}
fn unquoted(&self) -> &str {
panic!("Should not call this")
}
}
View on GitHub (pinned to e29bcd1b41)
Solutions
- No fix needed — this branch is unreachable by construction; do not catch it.
- If it fires, check for a custom `Iden`/identifier type whose `Display` implementation returns an error.
- Reduce identifier/row batch sizes if memory pressure is the cause.
Defensive patterns
Strategy: validation
Validate before calling
// Ensure identifiers implement Display and batches are bounded let s: String = vec.iter().map(|i| i.to_string()).collect(); debug_assert!(!s.is_empty() || vec.is_empty());
Type guard
fn is_infallible_write(res: fmt::Result) -> bool { res.is_ok() } Prevention
- Do not wrap infallible String writes with catchable panics in app code.
- Keep custom Iden Display impls error-free.
- Keep the sea-orm version consistent across the workspace to avoid mismatched identifier types.
When it happens
Trigger: Rendering an `Identity::Many` column identity (e.g. composite primary keys used in `column_tuple_in_condition` or joined-key queries) when `write!` on the internal `String` returns `Err` — practically only under OOM or a buggy custom ` Iden` Display impl.
Common situations: Composite/multi-column primary keys or multi-column foreign keys being converted to string identity during query building; almost never hit by real applications.
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/956c48e339531d66.
Report an issue: GitHub.