From 1a61209596ffc18a884b694df883d379555ed76a Mon Sep 17 00:00:00 2001 From: vishalsodani Date: Tue, 18 Oct 2022 19:41:06 +0530 Subject: [PATCH] fix wrong variant returned for invalid_api_key_indexes error --- meilisearch-auth/src/error.rs | 4 +++- meilisearch-http/tests/auth/api_keys.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/meilisearch-auth/src/error.rs b/meilisearch-auth/src/error.rs index bb96be789..46c244a5a 100644 --- a/meilisearch-auth/src/error.rs +++ b/meilisearch-auth/src/error.rs @@ -12,7 +12,9 @@ pub enum AuthControllerError { MissingParameter(&'static str), #[error("`actions` field value `{0}` is invalid. It should be an array of string representing action names.")] InvalidApiKeyActions(Value), - #[error("`indexes` field value `{0}` is invalid. It should be an array of string representing index names.")] + #[error( + "`{0}` is not a valid index uid. It should be an array of string representing index names." + )] InvalidApiKeyIndexes(Value), #[error("`expiresAt` field value `{0}` is invalid. It should follow the RFC 3339 format to represents a date or datetime in the future or specified as a null value. e.g. 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'.")] InvalidApiKeyExpiresAt(Value), diff --git a/meilisearch-http/tests/auth/api_keys.rs b/meilisearch-http/tests/auth/api_keys.rs index 7fdf2f129..658369802 100644 --- a/meilisearch-http/tests/auth/api_keys.rs +++ b/meilisearch-http/tests/auth/api_keys.rs @@ -350,7 +350,7 @@ async fn error_add_api_key_invalid_parameters_indexes() { assert_eq!(400, code, "{:?}", &response); let expected_response = json!({ - "message": r#"`indexes` field value `{"name":"products"}` is invalid. It should be an array of string representing index names."#, + "message": r#"`{"name":"products"}` is not a valid index uid. It should be an array of string representing index names."#, "code": "invalid_api_key_indexes", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_api_key_indexes" @@ -375,7 +375,7 @@ async fn error_add_api_key_invalid_index_uids() { let (response, code) = server.add_api_key(content).await; let expected_response = json!({ - "message": r#"`indexes` field value `["invalid index # / \\name with spaces"]` is invalid. It should be an array of string representing index names."#, + "message": r#"`["invalid index # / \\name with spaces"]` is not a valid index uid. It should be an array of string representing index names."#, "code": "invalid_api_key_indexes", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_api_key_indexes"