Skip to content

Commit 28cb32c

Browse files
Shiven0504bfops
andauthored
fix: Replace unwrap with proper error handling in set_domains handler (#4643)
Closes #4635 In `crates/client-api/src/routes/database.rs` line 1111, `lookup_database_identity` returns a `Result` but the error was handled with `.unwrap()`, which panics instead of returning an HTTP 500. Replaced it with `.map_err(log_and_500)?` to match the rest of the file. --------- Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent 6b1db9a commit 28cb32c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

crates/client-api/src/routes/database.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,12 @@ pub async fn set_names<S: ControlStateDelegate + Authorization>(
11071107
})?;
11081108

11091109
for name in &validated_names {
1110-
if ctx.lookup_database_identity(name.as_str()).await.unwrap().is_some() {
1110+
if ctx
1111+
.lookup_database_identity(name.as_str())
1112+
.await
1113+
.map_err(log_and_500)?
1114+
.is_some()
1115+
{
11111116
return Ok((
11121117
StatusCode::BAD_REQUEST,
11131118
axum::Json(name::SetDomainsResult::OtherError(format!(

0 commit comments

Comments
 (0)