nautechsystems/nautilus_trader · error · anyhow::Error

Execution payload rewrap batch size must be positive

Error message

Execution payload rewrap batch size must be positive

What it means

rewrap_execution_payload_storage processes retained payload rows in SQL batches, so the batch_size parameter must be a positive integer. An ensure! guards this up front and rejects non-positive values before any rewrap state changes are made.

Source

Thrown at crates/adapters/blockchain/src/cache/database.rs:5316

                protected: deployment_id.is_some(),
                deployment_id,
                plaintext_rows,
                original_rows,
                replacement_rows,
                authenticated_rows,
                key_ids: key_ids.into_iter().collect(),
                read_roles,
            },
            transaction,
        ))
    }

    pub(crate) async fn rewrap_execution_payload_storage(
        &self,
        keys: &PayloadKeySet,
        batch_size: i64,
    ) -> anyhow::Result<()> {
        anyhow::ensure!(
            batch_size > 0,
            "Execution payload rewrap batch size must be positive"
        );
        self.begin_execution_payload_rewrap(keys).await?;

        loop {
            if self
                .rewrap_execution_payload_batch(keys, batch_size)
                .await?
            {
                return Ok(());
            }
        }
    }

    async fn begin_execution_payload_rewrap(&self, keys: &PayloadKeySet) -> anyhow::Result<()> {
        let mut transaction = self
            .pool

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass a positive batch size, e.g. 500 or 1000 rows per batch.
  2. Fix the config source so an unset value falls back to a sane default instead of 0.
  3. Check casts/widening from unsigned types so negative or zero values cannot reach the call.

Example fix

// before
let batch_size: i64 = config.rewrap_batch_size.unwrap_or(0) as i64;
// after
let batch_size: i64 = config.rewrap_batch_size.unwrap_or(500).max(1) as i64;
Defensive patterns

Strategy: validation

Validate before calling

let batch_size = config.rewrap_batch_size.unwrap_or(500);
if batch_size <= 0 {
    return Err(anyhow!("rewrap batch size must be positive, got {batch_size}"));
}

Prevention

When it happens

Trigger: Calling rewrap_execution_payload_storage(keys, batch_size) with batch_size <= 0 (e.g. 0, a negative value, or an uninitialized/default i64).

Common situations: A config value for batch size parsed as 0 when unset; sign confusion when passing a usize/i32 cast into i64; a typo in operator config ("batch_size: 0" to mean unlimited).

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/ae2c25b58d983387. Report an issue: GitHub.