diff --git a/dump/src/reader/compat/v5_to_v6.rs b/dump/src/reader/compat/v5_to_v6.rs index 2fe99e2af..3f360e329 100644 --- a/dump/src/reader/compat/v5_to_v6.rs +++ b/dump/src/reader/compat/v5_to_v6.rs @@ -260,7 +260,7 @@ impl From for v6::ResponseError { "invalid_index_uid" => v6::Code::InvalidIndexUid, "invalid_min_word_length_for_typo" => v6::Code::InvalidMinWordLengthForTypo, "invalid_state" => v6::Code::InvalidState, - "primary_key_inference_failed" => v6::Code::MissingPrimaryKey, + "primary_key_inference_failed" => v6::Code::NoPrimaryKeyCandidateFound, "index_primary_key_already_exists" => v6::Code::PrimaryKeyAlreadyPresent, "max_fields_limit_exceeded" => v6::Code::MaxFieldsLimitExceeded, "missing_document_id" => v6::Code::MissingDocumentId, diff --git a/meilisearch-types/src/error.rs b/meilisearch-types/src/error.rs index e8b108595..846b690b0 100644 --- a/meilisearch-types/src/error.rs +++ b/meilisearch-types/src/error.rs @@ -126,7 +126,8 @@ pub enum Code { // invalid state error InvalidState, - MissingPrimaryKey, + NoPrimaryKeyCandidateFound, + MultiplePrimaryKeyCandidatesFound, PrimaryKeyAlreadyPresent, MaxFieldsLimitExceeded, @@ -211,9 +212,13 @@ impl Code { // invalid state error InvalidState => ErrCode::internal("invalid_state", StatusCode::INTERNAL_SERVER_ERROR), // thrown when no primary key has been set - MissingPrimaryKey => { - ErrCode::invalid("primary_key_inference_failed", StatusCode::BAD_REQUEST) + NoPrimaryKeyCandidateFound => { + ErrCode::invalid("index_primary_key_no_candidate_found", StatusCode::BAD_REQUEST) } + MultiplePrimaryKeyCandidatesFound => ErrCode::invalid( + "index_primary_key_multiple_candidates_found", + StatusCode::BAD_REQUEST, + ), // error thrown when trying to set an already existing primary key PrimaryKeyAlreadyPresent => { ErrCode::invalid("index_primary_key_already_exists", StatusCode::BAD_REQUEST) @@ -405,7 +410,10 @@ impl ErrorCode for milli::Error { UserError::InvalidDocumentId { .. } | UserError::TooManyDocumentIds { .. } => { Code::InvalidDocumentId } - UserError::MissingPrimaryKey => Code::MissingPrimaryKey, + UserError::NoPrimaryKeyCandidateFound => Code::NoPrimaryKeyCandidateFound, + UserError::MultiplePrimaryKeyCandidatesFound { .. } => { + Code::MultiplePrimaryKeyCandidatesFound + } UserError::PrimaryKeyCannotBeChanged(_) => Code::PrimaryKeyAlreadyPresent, UserError::SortRankingRuleMissing => Code::Sort, UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,