Prevent having both a fragment name and userProvided

This commit is contained in:
Mubelotix
2025-07-07 18:41:03 +02:00
parent 9c60e9689f
commit 5cced0af02

View File

@ -25,7 +25,6 @@ impl<'a> VectorFilter<'a> {
/// - `_vectors.{embedder_name}` /// - `_vectors.{embedder_name}`
/// - `_vectors.{embedder_name}.userProvided` /// - `_vectors.{embedder_name}.userProvided`
/// - `_vectors.{embedder_name}.fragments.{fragment_name}` /// - `_vectors.{embedder_name}.fragments.{fragment_name}`
/// - `_vectors.{embedder_name}.fragments.{fragment_name}.userProvided`
pub(super) fn parse(s: &'a str) -> Result<Self> { pub(super) fn parse(s: &'a str) -> Result<Self> {
let mut split = s.split('.').peekable(); let mut split = s.split('.').peekable();
@ -54,6 +53,12 @@ impl<'a> VectorFilter<'a> {
user_provided = true; user_provided = true;
} }
if fragment_name.is_some() && user_provided {
return Err(Error::UserError(UserError::InvalidFilter(
String::from("Vector filter cannot specify both a fragment name and userProvided"),
)));
}
if let Some(next) = split.next() { if let Some(next) = split.next() {
return Err(Error::UserError(UserError::InvalidFilter(format!( return Err(Error::UserError(UserError::InvalidFilter(format!(
"Unexpected part in vector filter: '{next}'" "Unexpected part in vector filter: '{next}'"