From cb0bb399fac46c95ec51524fea9ff05c18b9787b Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 7 Jun 2023 11:14:14 +0200 Subject: [PATCH] Fix the error code returned when the facetName field is missing --- meilisearch-types/src/deserr/mod.rs | 4 ++++ meilisearch-types/src/error.rs | 1 + meilisearch/src/routes/indexes/facet_search.rs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/meilisearch-types/src/deserr/mod.rs b/meilisearch-types/src/deserr/mod.rs index bbaa42dc0..df304cc2f 100644 --- a/meilisearch-types/src/deserr/mod.rs +++ b/meilisearch-types/src/deserr/mod.rs @@ -151,6 +151,10 @@ make_missing_field_convenience_builder!(MissingApiKeyExpiresAt, missing_api_key_ make_missing_field_convenience_builder!(MissingApiKeyIndexes, missing_api_key_indexes); make_missing_field_convenience_builder!(MissingSwapIndexes, missing_swap_indexes); make_missing_field_convenience_builder!(MissingDocumentFilter, missing_document_filter); +make_missing_field_convenience_builder!( + MissingFacetSearchFacetName, + missing_facet_search_facet_name +); // Integrate a sub-error into a [`DeserrError`] by taking its error message but using // the default error code (C) from `Self` diff --git a/meilisearch-types/src/error.rs b/meilisearch-types/src/error.rs index c7ab6fa0f..004c85376 100644 --- a/meilisearch-types/src/error.rs +++ b/meilisearch-types/src/error.rs @@ -288,6 +288,7 @@ MissingApiKeyIndexes , InvalidRequest , BAD_REQUEST ; MissingAuthorizationHeader , Auth , UNAUTHORIZED ; MissingContentType , InvalidRequest , UNSUPPORTED_MEDIA_TYPE ; MissingDocumentId , InvalidRequest , BAD_REQUEST ; +MissingFacetSearchFacetName , InvalidRequest , BAD_REQUEST ; MissingIndexUid , InvalidRequest , BAD_REQUEST ; MissingMasterKey , Auth , UNAUTHORIZED ; MissingPayload , InvalidRequest , BAD_REQUEST ; diff --git a/meilisearch/src/routes/indexes/facet_search.rs b/meilisearch/src/routes/indexes/facet_search.rs index b56495c5a..d07a22257 100644 --- a/meilisearch/src/routes/indexes/facet_search.rs +++ b/meilisearch/src/routes/indexes/facet_search.rs @@ -30,7 +30,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { pub struct FacetSearchQuery { #[deserr(default, error = DeserrJsonError)] pub facet_query: Option, - #[deserr(error = DeserrJsonError)] + #[deserr(error = DeserrJsonError, missing_field_error = DeserrJsonError::missing_facet_search_facet_name)] pub facet_name: String, #[deserr(default, error = DeserrJsonError)] pub q: Option,