diff --git a/src/models/menu_tree.rs b/src/models/menu_tree.rs index 3d1bfb4..98563fb 100644 --- a/src/models/menu_tree.rs +++ b/src/models/menu_tree.rs @@ -126,9 +126,11 @@ pub async fn menu_tree_from_id(_id: Option, _dictionary_code: Option<&St let mut _document = MenuTree::from_id(_id); let mut _index_name = "menu_tree".to_string(); - if _dictionary_code.is_some() { - _index_name.push_str("_"); - _index_name.push_str(_dictionary_code.unwrap()); + if let Some(code) = _dictionary_code { + if !code.trim().is_empty() { + _index_name.push_str("_"); + _index_name.push_str(code); + } } log::info!("Index to search {:}", _index_name); diff --git a/src/models/role.rs b/src/models/role.rs index a13f3d4..4f24776 100644 --- a/src/models/role.rs +++ b/src/models/role.rs @@ -168,8 +168,10 @@ pub async fn role_from_id(_id: Option<&String>, _client_id: Option<&String>, _di } async fn get_index_name(_client_id: Option<&String>) -> Result { - if _client_id.is_none() { - return Err(Error::new(ErrorKind::InvalidData.into(), "Client is Mandatory")); + if _client_id.is_none() || _client_id.as_deref().map_or(false, |s| s.trim().is_empty()) { + return Err( + Error::new(ErrorKind::InvalidData.into(), "Client is Mandatory") + ); } let _base_index: String = "role".to_string();