diff --git a/meilisearch-types/src/error.rs b/meilisearch-types/src/error.rs index bf9492ff6..aed77411a 100644 --- a/meilisearch-types/src/error.rs +++ b/meilisearch-types/src/error.rs @@ -259,7 +259,7 @@ InvalidSettingsProximityPrecision , InvalidRequest , BAD_REQUEST ; InvalidSettingsFaceting , InvalidRequest , BAD_REQUEST ; InvalidSettingsFilterableAttributes , InvalidRequest , BAD_REQUEST ; InvalidSettingsPagination , InvalidRequest , BAD_REQUEST ; -InvalidSettingsSearchCutoff , InvalidRequest , BAD_REQUEST ; +InvalidSettingsSearchCutoffMs , InvalidRequest , BAD_REQUEST ; InvalidSettingsEmbedders , InvalidRequest , BAD_REQUEST ; InvalidSettingsRankingRules , InvalidRequest , BAD_REQUEST ; InvalidSettingsSearchableAttributes , InvalidRequest , BAD_REQUEST ; diff --git a/meilisearch-types/src/settings.rs b/meilisearch-types/src/settings.rs index 23fe98347..5480e72c6 100644 --- a/meilisearch-types/src/settings.rs +++ b/meilisearch-types/src/settings.rs @@ -203,7 +203,7 @@ pub struct Settings { #[deserr(default, error = DeserrJsonError)] pub embedders: Setting>>, #[serde(default, skip_serializing_if = "Setting::is_not_set")] - #[deserr(default, error = DeserrJsonError)] + #[deserr(default, error = DeserrJsonError)] pub search_cutoff_ms: Setting, #[serde(skip)] diff --git a/meilisearch/src/routes/indexes/settings.rs b/meilisearch/src/routes/indexes/settings.rs index 4c03eb1a1..5dabd7b0d 100644 --- a/meilisearch/src/routes/indexes/settings.rs +++ b/meilisearch/src/routes/indexes/settings.rs @@ -138,7 +138,6 @@ macro_rules! make_setting_route { debug!(returns = ?settings, "Update settings"); let mut json = serde_json::json!(&settings); - dbg!(&json); let val = json[$camelcase_attr].take(); Ok(HttpResponse::Ok().json(val)) @@ -630,7 +629,7 @@ make_setting_route!( put, u64, meilisearch_types::deserr::DeserrJsonError< - meilisearch_types::error::deserr_codes::InvalidSettingsSearchCutoff, + meilisearch_types::error::deserr_codes::InvalidSettingsSearchCutoffMs, >, search_cutoff_ms, "searchCutoffMs", diff --git a/meilisearch/tests/common/index.rs b/meilisearch/tests/common/index.rs index 16fc10e98..9ed6a6077 100644 --- a/meilisearch/tests/common/index.rs +++ b/meilisearch/tests/common/index.rs @@ -328,6 +328,11 @@ impl Index<'_> { self.service.patch_encoded(url, settings, self.encoder).await } + pub async fn update_settings_search_cutoff_ms(&self, settings: Value) -> (Value, StatusCode) { + let url = format!("/indexes/{}/settings/search-cutoff-ms", urlencode(self.uid.as_ref())); + self.service.put_encoded(url, settings, self.encoder).await + } + pub async fn delete_settings(&self) -> (Value, StatusCode) { let url = format!("/indexes/{}/settings", urlencode(self.uid.as_ref())); self.service.delete(url).await diff --git a/meilisearch/tests/settings/errors.rs b/meilisearch/tests/settings/errors.rs index 687cef1f8..2bd17d649 100644 --- a/meilisearch/tests/settings/errors.rs +++ b/meilisearch/tests/settings/errors.rs @@ -337,3 +337,31 @@ async fn settings_bad_pagination() { } "###); } + +#[actix_rt::test] +async fn settings_bad_search_cutoff_ms() { + let server = Server::new().await; + let index = server.index("test"); + + let (response, code) = index.update_settings(json!({ "searchCutoffMs": "doggo" })).await; + snapshot!(code, @"400 Bad Request"); + snapshot!(json_string!(response), @r###" + { + "message": "Invalid value type at `.searchCutoffMs`: expected a positive integer, but found a string: `\"doggo\"`", + "code": "invalid_settings_search_cutoff_ms", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_settings_search_cutoff_ms" + } + "###); + + let (response, code) = index.update_settings_search_cutoff_ms(json!("doggo")).await; + snapshot!(code, @"400 Bad Request"); + snapshot!(json_string!(response), @r###" + { + "message": "Invalid value type: expected a positive integer, but found a string: `\"doggo\"`", + "code": "invalid_settings_search_cutoff_ms", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_settings_search_cutoff_ms" + } + "###); +}