Skip to content

Unwrap in set_domains handler can panic the server instead of returning HTTP 500 #4635

@Shiven0504

Description

@Shiven0504

Description:

In crates/client-api/src/routes/database.rs line 1111, there's a .unwrap() on a database lookup that can fail:
if ctx.lookup_database_identity(name.as_str()).await.unwrap().is_some() {
Here the lookup_database_identity returns a result, so if the lookup ever fails (like control DB hiccup), this panics instead of returning a
proper HTTP 500.

Every other fallible call in this file uses .map_err(log_and_500)? to convert errors into a proper HTTP 500 response. This single .unwrap() is inconsistent and will cause a panic instead.

Expected behavior:

The lookup error should be handled consistently with the rest of the codebase:
if ctx.lookup_database_identity(name.as_str()).await.map_err(log_and_500)?.is_some() {

Steps to reproduce:
This will require inducing a failure in the control DB layer while a set_domains request is in flight, i dont think its easily reproducible
manually, but the code path is clearly reachable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions