{"record":{"id":"3ef68193209781e8","repo":"nautechsystems/nautilus_trader","slug":"payload-operation-batch-size-must-be-between-1-and","errorCode":null,"errorMessage":"Payload operation batch size must be between 1 and {MAX_PAYLOAD_OPERATION_BATCH_SIZE}","messagePattern":"Payload operation batch size must be between 1 and (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":3590,"sourceCode":"\nfn replacement_scan_range(from_block: u64, head_block: u64) -> anyhow::Result<RangeInclusive<u64>> {\n    anyhow::ensure!(\n        head_block >= from_block,\n        \"Canonical head {head_block} is behind execution creation block {from_block}\"\n    );\n    let max_end = from_block.saturating_add(MAX_REPLACEMENT_SCAN_BLOCKS - 1);\n    Ok(from_block..=head_block.min(max_end))\n}\n\nfn current_unix_secs() -> anyhow::Result<u64> {\n    SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .map_err(|_| anyhow::anyhow!(\"Trusted host clock precedes the Unix epoch\"))\n        .map(|duration| duration.as_secs())\n}\n\nfn validate_payload_operation_batch_size(batch_size: usize) -> anyhow::Result<i64> {\n    anyhow::ensure!(\n        (1..=MAX_PAYLOAD_OPERATION_BATCH_SIZE).contains(&batch_size),\n        \"Payload operation batch size must be between 1 and {MAX_PAYLOAD_OPERATION_BATCH_SIZE}\"\n    );\n    Ok(i64::try_from(batch_size).expect(\"bounded payload batch size fits i64\"))\n}\n\nfn current_execution_hash(\n    intent_id: i64,\n    hashes: &[ExecutionTransactionHashRow],\n) -> anyhow::Result<&ExecutionTransactionHashRow> {\n    let mut current = hashes.iter().filter(|row| row.current);\n    let row = current\n        .next()\n        .ok_or_else(|| anyhow::anyhow!(\"Execution intent {intent_id} has no current hash\"))?;\n    anyhow::ensure!(\n        current.next().is_none(),\n        \"Execution intent {intent_id} has more than one current hash\"\n    );","sourceCodeStart":3572,"sourceCodeEnd":3608,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L3572-L3608","documentation":"`validate_payload_operation_batch_size` enforces that the caller-supplied payload operation batch size is within [1, MAX_PAYLOAD_OPERATION_BATCH_SIZE] before converting it to i64. Values of 0 or above the maximum are rejected since the batch protocol requires a bounded, positive batch size.","triggerScenarios":"Configuring or calling payload operation submission with `batch_size = 0` or `batch_size > MAX_PAYLOAD_OPERATION_BATCH_SIZE` — e.g. a config file with `payload_batch_size: 0`, or a user trying to 'send everything at once' with an oversized value.","commonSituations":"Zero interpreted as 'unlimited' by users; copy-pasting a batch size from another adapter with a different maximum; environment variable parsed into 0 on malformed input.","solutions":["Set the batch size to a value between 1 and MAX_PAYLOAD_OPERATION_BATCH_SIZE (check the constant for the current limit).","Clamp or validate the configured value at config-load time.","If a larger batch is genuinely needed, raise the constant in code rather than passing an out-of-range runtime value."],"exampleFix":"// before\npayload_batch_size = 0\n// after\npayload_batch_size = 50  // 1 <= n <= MAX_PAYLOAD_OPERATION_BATCH_SIZE","handlingStrategy":"validation","validationCode":"const MAX: usize = MAX_PAYLOAD_OPERATION_BATCH_SIZE as usize;\nanyhow::ensure!((1..=MAX).contains(&batch_size), \"batch_size {batch_size} outside 1..={MAX}\");","typeGuard":null,"tryCatchPattern":"match validate_payload_operation_batch_size(cfg.batch_size) {\n    Err(_) => use_default_batch_size(),\n    Ok(size) => submit_with_batch_size(size),\n}","preventionTips":["Validate batch size at config-load time, not at call time","Never use 0 to mean 'unlimited'; use the documented default","Clamp parsed values into [1, MAX_PAYLOAD_OPERATION_BATCH_SIZE]"],"tags":["config","validation","batching","bounds"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}