From 85e3c9c97bfeacab533df0faa64987549028848f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=BA=20Ho=C3=A0ng?= Date: Mon, 15 Sep 2025 17:41:53 +0700 Subject: [PATCH] Fix: Handle optional api_key_id in Redis instance deletion This commit fixes a database decoding error during the Redis instance deletion process. The `try_get` call in `delete_redis_instance` failed when the `api_key_id` column was `NULL` in the database. The fix involves changing the `api_key_id` variable to `Option` and wrapping the API key deactivation logic in a conditional block to handle cases where the key does not exist. This ensures that instances without an associated API key can be deleted successfully. --- src/handlers/redis_instances.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/redis_instances.rs b/src/handlers/redis_instances.rs index 2543242..63a0bd3 100644 --- a/src/handlers/redis_instances.rs +++ b/src/handlers/redis_instances.rs @@ -529,7 +529,7 @@ pub async fn delete_redis_instance( let namespace: Option = redis_instance.try_get("namespace").ok(); let slug: Option = redis_instance.try_get("slug").ok(); - let api_key_id: uuid::Uuid = redis_instance.try_get("api_key_id").map_err(|e| { + let api_key_id: Option = redis_instance.try_get("api_key_id").map_err(|e| { ( StatusCode::INTERNAL_SERVER_ERROR, Json(ApiResponse::<()>::error(format!("Database field error: {}", e))),