Skip to content

Commit d13aed5

Browse files
committed
Enforce max batch size in CustomPredicateBatchBuilder
1 parent 9964b6e commit d13aed5

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

src/frontend/custom.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ impl CustomPredicateBatchBuilder {
184184
priv_args: &[&str],
185185
sts: &[StatementTmplBuilder],
186186
) -> Result<Predicate> {
187+
if self.predicates.len() >= self.params.max_custom_batch_size {
188+
return Err(Error::max_length(
189+
"self.predicates.len".to_string(),
190+
self.predicates.len(),
191+
self.params.max_custom_batch_size,
192+
));
193+
}
194+
187195
if args.len() > self.params.max_statement_args {
188196
return Err(Error::max_length(
189197
"args.len".to_string(),

src/lang/processor.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,6 @@ fn second_pass(ctx: &mut ProcessingContext) -> Result<ProcessedOutput, Processor
208208

209209
let custom_batch = cpb_builder.finish();
210210

211-
if custom_batch.predicates.len() > ctx.params.max_custom_batch_size {
212-
return Err(ProcessorError::Middleware(middleware::Error::max_length(
213-
"custom predicates".to_string(),
214-
custom_batch.predicates.len(),
215-
ctx.params.max_custom_batch_size,
216-
)));
217-
}
218-
219211
let request_templates = if let Some(req_pair) = &ctx.request_pair {
220212
process_request_def(req_pair, ctx, &custom_batch)?
221213
} else {

src/middleware/custom.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,6 @@ pub struct CustomPredicateBatch {
379379
impl ToFields for CustomPredicateBatch {
380380
fn to_fields(&self, params: &Params) -> Vec<F> {
381381
// all the custom predicates in order
382-
383-
// TODO think if this check should go into the StatementTmpl creation,
384-
// instead of at the `to_fields` method, where we should assume that the
385-
// values are already valid
386-
if self.predicates.len() > params.max_custom_batch_size {
387-
panic!("Predicate batch exceeds maximum size");
388-
}
389-
390382
let pad_pred = CustomPredicate::empty();
391383
let fields: Vec<F> = self
392384
.predicates

0 commit comments

Comments
 (0)