Zackriya-Solutions/meetily · error · anyhow::Error
Failed to insert transcript: {}
Error message
Failed to insert transcript: {} What it means
One of the INSERT statements for the new transcript segments failed, aborting the save. Because delete and inserts share one transaction, the whole batch rolls back and the meeting keeps its previous transcripts - that rollback is the intended data-loss guard. The inner '{}' usually names a constraint: NOT NULL violation (empty text, NULL timestamp/duration), a CHECK/FK violation, or a type mismatch in a bound column.
Source
Thrown at frontend/src-tauri/src/audio/retranscription.rs:456
.execute(&mut *tx)
.await
.map_err(|e| anyhow!("Failed to delete existing transcripts: {}", e))?;
for segment in &segments {
sqlx::query(
"INSERT INTO transcripts (id, meeting_id, transcript, timestamp, audio_start_time, audio_end_time, duration)
VALUES (?, ?, ?, ?, ?, ?, ?)"
)
.bind(&segment.id)
.bind(&meeting_id)
.bind(&segment.text)
.bind(&segment.timestamp)
.bind(segment.audio_start_time)
.bind(segment.audio_end_time)
.bind(segment.duration)
.execute(&mut *tx)
.await
.map_err(|e| anyhow!("Failed to insert transcript: {}", e))?;
}
tx.commit().await
.map_err(|e| anyhow!("Failed to commit transaction: {}", e))?;
info!(
"Updated {} transcripts for meeting {} in transaction",
segments.len(),
meeting_id
);
// Write updated transcripts.json and metadata.json to the meeting folder
emit_progress(&app, &meeting_id, "saving", 90, "Writing transcript files...");
if let Err(e) = write_transcripts_json(&folder_path, &segments) {
warn!("Failed to write transcripts.json: {}", e);
}
View on GitHub (pinned to 0281737d87)
Solutions
- Read the inner error - it names the exact failed constraint or column.
- Log the offending segment's id/text/timestamps when this error fires to identify which field is bad.
- Filter and normalize segments before insert: skip empty text, clamp non-finite timestamps and durations to defaults.
- If the error is a schema mismatch, run the app's migrations so transcripts matches the INSERT shape.
Example fix
// before: insert every segment blindly
for segment in &segments {
sqlx::query("INSERT INTO transcripts ...")...
}
// after: skip segments that cannot satisfy constraints
for segment in &segments {
if segment.text.trim().is_empty()
|| !segment.audio_start_time.map_or(false, |v| v.is_finite())
{
warn!("Skipping invalid transcript segment {}");
continue;
}
sqlx::query("INSERT INTO transcripts ...")...
} Defensive patterns
Strategy: validation
Validate before calling
// Validate every segment against the table's constraints before the transaction
fn segment_is_insertable(s: &TranscriptSegment) -> bool {
!s.text.trim().is_empty()
&& !s.id.is_empty()
&& s.timestamp.is_finite()
&& s.audio_start_time.map_or(false, |v| v.is_finite())
&& s.audio_end_time.map_or(false, |v| v.is_finite())
} Try / catch
// Log the offending row so the failing column is identifiable
if let Err(e) = insert_result {
error!("insert failed for segment id={} text_len={}: {e}", segment.id, segment.text.len());
return Err(anyhow!("Failed to insert transcript: {e}"));
} Prevention
- Filter empty-text and non-finite-timestamp segments before insert.
- Keep struct fields and table columns in sync via migrations whenever the INSERT shape changes.
- Rely on the surrounding transaction: a failed insert rolls back the delete, so old data survives.
When it happens
Trigger: A segment whose text is empty or whose audio_start_time/audio_end_time/duration bound as NULL against a NOT NULL column; schema drift where struct fields no longer match table columns (for example duration column added by a newer migration); a duplicate primary key id.
Common situations: An older database file used with a newer app build that inserts new columns; create_transcript_segments producing an empty-text row through an edge case; timestamp math yielding NaN for a zero-length segment.
Related errors
- Failed to create meeting: {}
- Failed to insert transcript: {}
- DB error: {}
- Failed to start transaction: {}
- Failed to commit transaction: {}
AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16).
Data as JSON: /api/errors/c8a998b8965801c9.
Report an issue: GitHub.