diff --git a/meilisearch-types/src/error.rs b/meilisearch-types/src/error.rs index 97761a138..bcd8320c9 100644 --- a/meilisearch-types/src/error.rs +++ b/meilisearch-types/src/error.rs @@ -214,15 +214,12 @@ InvalidApiKeyUid , InvalidRequest , BAD_REQUEST ; InvalidContentType , InvalidRequest , UNSUPPORTED_MEDIA_TYPE ; InvalidDocumentCsvDelimiter , InvalidRequest , BAD_REQUEST ; InvalidDocumentFields , InvalidRequest , BAD_REQUEST ; +InvalidDocumentFilter , InvalidRequest , BAD_REQUEST ; InvalidDocumentGeoField , InvalidRequest , BAD_REQUEST ; InvalidDocumentId , InvalidRequest , BAD_REQUEST ; InvalidDocumentLimit , InvalidRequest , BAD_REQUEST ; InvalidDocumentOffset , InvalidRequest , BAD_REQUEST ; InvalidDocumentDeleteFilter , InvalidRequest , BAD_REQUEST ; -InvalidDocumentGetOffset , InvalidRequest , BAD_REQUEST ; -InvalidDocumentGetLimit , InvalidRequest , BAD_REQUEST ; -InvalidDocumentGetFields , InvalidRequest , BAD_REQUEST ; -InvalidDocumentGetFilter , InvalidRequest , BAD_REQUEST ; InvalidIndexLimit , InvalidRequest , BAD_REQUEST ; InvalidIndexOffset , InvalidRequest , BAD_REQUEST ; InvalidIndexPrimaryKey , InvalidRequest , BAD_REQUEST ; diff --git a/meilisearch/src/routes/indexes/documents.rs b/meilisearch/src/routes/indexes/documents.rs index 91d214c61..eb0f5a59e 100644 --- a/meilisearch/src/routes/indexes/documents.rs +++ b/meilisearch/src/routes/indexes/documents.rs @@ -140,20 +140,20 @@ pub struct BrowseQueryGet { limit: Param, #[deserr(default, error = DeserrQueryParamError)] fields: OptionStarOrList, - #[deserr(default, error = DeserrQueryParamError)] + #[deserr(default, error = DeserrQueryParamError)] filter: Option, } #[derive(Debug, Deserr)] #[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)] pub struct BrowseQuery { - #[deserr(default, error = DeserrJsonError)] + #[deserr(default, error = DeserrJsonError)] offset: usize, - #[deserr(default = PAGINATION_DEFAULT_LIMIT, error = DeserrJsonError)] + #[deserr(default = PAGINATION_DEFAULT_LIMIT, error = DeserrJsonError)] limit: usize, - #[deserr(default, error = DeserrJsonError)] + #[deserr(default, error = DeserrJsonError)] fields: Option>, - #[deserr(default, error = DeserrJsonError)] + #[deserr(default, error = DeserrJsonError)] filter: Option, } @@ -533,9 +533,8 @@ fn retrieve_documents>( let rtxn = index.read_txn()?; let filter = &filter; let filter = if let Some(filter) = filter { - parse_filter(filter).map_err(|err| { - ResponseError::from_msg(err.to_string(), Code::InvalidDocumentGetFilter) - })? + parse_filter(filter) + .map_err(|err| ResponseError::from_msg(err.to_string(), Code::InvalidDocumentFilter))? } else { None }; diff --git a/meilisearch/tests/documents/errors.rs b/meilisearch/tests/documents/errors.rs index 2ed70f9fc..d9c70d6ad 100644 --- a/meilisearch/tests/documents/errors.rs +++ b/meilisearch/tests/documents/errors.rs @@ -168,9 +168,9 @@ async fn get_all_documents_bad_filter() { snapshot!(json_string!(response), @r###" { "message": "Was expecting an operation `=`, `!=`, `>=`, `>`, `<=`, `<`, `IN`, `NOT IN`, `TO`, `EXISTS`, `NOT EXISTS`, `IS NULL`, `IS NOT NULL`, `IS EMPTY`, `IS NOT EMPTY`, `_geoRadius`, or `_geoBoundingBox` at `doggo`.\n1:6 doggo", - "code": "invalid_document_get_filter", + "code": "invalid_document_filter", "type": "invalid_request", - "link": "https://docs.meilisearch.com/errors#invalid_document_get_filter" + "link": "https://docs.meilisearch.com/errors#invalid_document_filter" } "###); @@ -709,9 +709,9 @@ async fn fetch_document_by_filter() { snapshot!(json_string!(response), @r###" { "message": "Invalid value type at `.offset`: expected a positive integer, but found a string: `\"doggo\"`", - "code": "invalid_document_get_offset", + "code": "invalid_document_offset", "type": "invalid_request", - "link": "https://docs.meilisearch.com/errors#invalid_document_get_offset" + "link": "https://docs.meilisearch.com/errors#invalid_document_offset" } "###); @@ -720,9 +720,9 @@ async fn fetch_document_by_filter() { snapshot!(json_string!(response), @r###" { "message": "Invalid value type at `.limit`: expected a positive integer, but found a string: `\"doggo\"`", - "code": "invalid_document_get_limit", + "code": "invalid_document_limit", "type": "invalid_request", - "link": "https://docs.meilisearch.com/errors#invalid_document_get_limit" + "link": "https://docs.meilisearch.com/errors#invalid_document_limit" } "###); @@ -731,9 +731,9 @@ async fn fetch_document_by_filter() { snapshot!(json_string!(response), @r###" { "message": "Invalid value type at `.fields`: expected an array, but found a string: `\"doggo\"`", - "code": "invalid_document_get_fields", + "code": "invalid_document_fields", "type": "invalid_request", - "link": "https://docs.meilisearch.com/errors#invalid_document_get_fields" + "link": "https://docs.meilisearch.com/errors#invalid_document_fields" } "###); @@ -742,9 +742,9 @@ async fn fetch_document_by_filter() { snapshot!(json_string!(response), @r###" { "message": "Invalid syntax for the filter parameter: `expected String, Array, found: true`.", - "code": "invalid_document_get_filter", + "code": "invalid_document_filter", "type": "invalid_request", - "link": "https://docs.meilisearch.com/errors#invalid_document_get_filter" + "link": "https://docs.meilisearch.com/errors#invalid_document_filter" } "###); }