Skip to content

Commit c05df46

Browse files
authored
Fix missing gRPC API validations for PointsSelector (#7221)
1 parent a458975 commit c05df46

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

lib/api/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ fn configure_validation(builder: Builder) -> Builder {
191191
], &[])
192192
// Service: points.proto
193193
.validates(&[
194+
("PointsSelector.points_selector_one_of", ""),
194195
("UpsertPoints.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
195196
("UpsertPoints.points", ""),
196197
("UpsertPoints.update_filter", ""),
@@ -200,11 +201,15 @@ fn configure_validation(builder: Builder) -> Builder {
200201
("UpdatePointVectors.update_filter", ""),
201202
("DeletePointVectors.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
202203
("DeletePointVectors.vector_names", "length(min = 1, message = \"must specify vector names to delete\")"),
204+
("DeletePointVectors.points_selector", ""),
203205
("PointVectors.vectors", ""),
204206
("GetPoints.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
205207
("SetPayloadPoints.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
208+
("SetPayloadPoints.points_selector", ""),
206209
("DeletePayloadPoints.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
210+
("DeletePayloadPoints.points_selector", ""),
207211
("ClearPayloadPoints.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
212+
("ClearPayloadPoints.points", ""),
208213
("UpdateBatchPoints.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),
209214
("UpdateBatchPoints.operations", "length(min = 1)"),
210215
("CreateFieldIndexCollection.collection_name", "length(min = 1, max = 255), custom(function = \"common::validation::validate_collection_name_legacy\")"),

lib/api/src/grpc/qdrant.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,6 +4496,7 @@ pub struct DeletePointVectors {
44964496
pub wait: ::core::option::Option<bool>,
44974497
/// Affected points
44984498
#[prost(message, optional, tag = "3")]
4499+
#[validate(nested)]
44994500
pub points_selector: ::core::option::Option<PointsSelector>,
45004501
/// List of vector names to delete
45014502
#[prost(message, optional, tag = "4")]
@@ -4527,6 +4528,7 @@ pub struct SetPayloadPoints {
45274528
pub payload: ::std::collections::HashMap<::prost::alloc::string::String, Value>,
45284529
/// Affected points
45294530
#[prost(message, optional, tag = "5")]
4531+
#[validate(nested)]
45304532
pub points_selector: ::core::option::Option<PointsSelector>,
45314533
/// Write ordering guarantees
45324534
#[prost(message, optional, tag = "6")]
@@ -4558,6 +4560,7 @@ pub struct DeletePayloadPoints {
45584560
pub keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
45594561
/// Affected points
45604562
#[prost(message, optional, tag = "5")]
4563+
#[validate(nested)]
45614564
pub points_selector: ::core::option::Option<PointsSelector>,
45624565
/// Write ordering guarantees
45634566
#[prost(message, optional, tag = "6")]
@@ -4583,6 +4586,7 @@ pub struct ClearPayloadPoints {
45834586
pub wait: ::core::option::Option<bool>,
45844587
/// Affected points
45854588
#[prost(message, optional, tag = "3")]
4589+
#[validate(nested)]
45864590
pub points: ::core::option::Option<PointsSelector>,
45874591
/// Write ordering guarantees
45884592
#[prost(message, optional, tag = "4")]
@@ -6862,11 +6866,13 @@ pub struct ValuesCount {
68626866
#[prost(uint64, optional, tag = "4")]
68636867
pub lte: ::core::option::Option<u64>,
68646868
}
6869+
#[derive(validator::Validate)]
68656870
#[derive(serde::Serialize)]
68666871
#[allow(clippy::derive_partial_eq_without_eq)]
68676872
#[derive(Clone, PartialEq, ::prost::Message)]
68686873
pub struct PointsSelector {
68696874
#[prost(oneof = "points_selector::PointsSelectorOneOf", tags = "1, 2")]
6875+
#[validate(nested)]
68706876
pub points_selector_one_of: ::core::option::Option<
68716877
points_selector::PointsSelectorOneOf,
68726878
>,

lib/api/src/grpc/validate.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,15 @@ impl Validate for super::qdrant::IntegerIndexParams {
478478
}
479479
}
480480

481+
impl Validate for super::qdrant::points_selector::PointsSelectorOneOf {
482+
fn validate(&self) -> Result<(), ValidationErrors> {
483+
match self {
484+
grpc::points_selector::PointsSelectorOneOf::Points(_) => Ok(()),
485+
grpc::points_selector::PointsSelectorOneOf::Filter(filter) => filter.validate(),
486+
}
487+
}
488+
}
489+
481490
#[cfg(test)]
482491
mod tests {
483492
use validator::Validate;

0 commit comments

Comments
 (0)