nautechsystems/nautilus_trader · error · anyhow::Error
Execution payload check batch size must be positive
Error message
Execution payload check batch size must be positive
What it means
Input guard for execution payload storage checks: the batch_size passed to the storage inspection is zero or negative, which would produce an empty or invalid page, so the check is rejected before querying.
Source
Thrown at crates/adapters/blockchain/src/cache/database.rs:5115
batch_size: i64,
) -> anyhow::Result<ExecutionPayloadCheck> {
let (check, transaction) = self
.inspect_execution_payload_storage(keys, policy, batch_size)
.await?;
transaction
.commit()
.await
.context("failed to complete execution payload check")?;
Ok(check)
}
async fn inspect_execution_payload_storage(
&self,
keys: Option<&PayloadKeySet>,
policy: Option<PayloadPolicy>,
batch_size: i64,
) -> anyhow::Result<(ExecutionPayloadCheck, Transaction<'static, Postgres>)> {
anyhow::ensure!(
batch_size > 0,
"Execution payload check batch size must be positive"
);
let mut transaction = self
.pool
.begin()
.await
.context("failed to start execution payload check")?;
sqlx::query("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")
.execute(&mut *transaction)
.await
.context("failed to stabilize execution payload snapshot")?;
sqlx::query("LOCK TABLE execution_transaction_hash IN SHARE MODE")
.execute(&mut *transaction)
.await
.context("failed to stabilize execution payload check")?;
let marker = sqlx::query_scalar::<_, i16>(
"SELECT version FROM execution_schema_version WHERE component = $1",View on GitHub (pinned to 18893faf8b)
Solutions
- Pass batch_size >= 1
- Clamp or default the configured value before calling (e.g. batch_size.max(1))
- Fix the config source that produced 0/negative
- Validate numeric config at load time
Example fix
// before let check = storage.inspect_execution_payload_storage(None, None, config.batch_size).await?; // after let batch = config.batch_size.max(1); let check = storage.inspect_execution_payload_storage(None, None, batch).await?;
Defensive patterns
Strategy: validation
Validate before calling
fn valid_batch_size(v: i64) -> bool { v > 0 } Type guard
fn is_positive_batch(v: i64) -> Option<std::num::NonZeroI64> { std::num::NonZeroI64::new(v) } Try / catch
match inspect_storage(keys, policy, batch_size).await {
Err(e) if e.to_string().contains("batch size must be positive") => inspect_storage(keys, policy, batch_size.max(1)).await,
other => other,
} Prevention
- Use NonZeroI64 for batch-size parameters
- Validate numeric config fields at load time
- Never pass 0 as a default/placeholder batch size
- Parse env/config values with explicit fallbacks
When it happens
Trigger: Calling inspect_execution_payload_storage with batch_size = 0 or a negative i64, typically from unvalidated configuration or a default-initialized parameter.
Common situations: Config file with batch_size: 0; parsing an empty/invalid env value into 0; a caller passing a placeholder before computing a real batch size.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Wrap amount must be positive
- max_fee_per_contract is required
- max_fee_per_contract must be greater than zero
- Failed to create HTTP client: {e}
- Connect verification evidence is incomplete
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/ab4f07ee3b627acb.
Report an issue: GitHub.