fix wrong variant returned for invalid_api_key_indexes error

This commit is contained in:
vishalsodani 2022-10-18 19:41:06 +05:30
parent 96acbf815d
commit 1a61209596
2 changed files with 5 additions and 3 deletions

View File

@ -12,7 +12,9 @@ pub enum AuthControllerError {
MissingParameter(&'static str), MissingParameter(&'static str),
#[error("`actions` field value `{0}` is invalid. It should be an array of string representing action names.")] #[error("`actions` field value `{0}` is invalid. It should be an array of string representing action names.")]
InvalidApiKeyActions(Value), 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), 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'.")] #[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), InvalidApiKeyExpiresAt(Value),

View File

@ -350,7 +350,7 @@ async fn error_add_api_key_invalid_parameters_indexes() {
assert_eq!(400, code, "{:?}", &response); assert_eq!(400, code, "{:?}", &response);
let expected_response = json!({ 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", "code": "invalid_api_key_indexes",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_api_key_indexes" "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 (response, code) = server.add_api_key(content).await;
let expected_response = json!({ 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", "code": "invalid_api_key_indexes",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_api_key_indexes" "link": "https://docs.meilisearch.com/errors#invalid_api_key_indexes"