Skip to content

Commit

Permalink
Stop panicking when our accounting is wrong (#4568)
Browse files Browse the repository at this point in the history
Prefer to return a 500 error instead of panicking.

Since this function is already called from a transactional context, we
can rely on the rollback mechanism to "undo" the deletion.

Fixes #3870
  • Loading branch information
smklein authored Nov 29, 2023
1 parent a4e1216 commit 22a70e4
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ impl DataStore {
.get_result_async(conn)
.await
.map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))?;
assert!(
collection.is_empty(),
"Collection deleted while non-empty: {collection:?}"
);

if !collection.is_empty() {
return Err(Error::internal_error(&format!(
"Collection deleted while non-empty: {collection:?}"
)));
}
Ok(())
}

Expand Down

0 comments on commit 22a70e4

Please sign in to comment.