{"record":{"id":"ae2c25b58d983387","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-rewrap-batch-size-must-be-positi","errorCode":null,"errorMessage":"Execution payload rewrap batch size must be positive","messagePattern":"Execution payload rewrap batch size must be positive","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":5316,"sourceCode":"                protected: deployment_id.is_some(),\n                deployment_id,\n                plaintext_rows,\n                original_rows,\n                replacement_rows,\n                authenticated_rows,\n                key_ids: key_ids.into_iter().collect(),\n                read_roles,\n            },\n            transaction,\n        ))\n    }\n\n    pub(crate) async fn rewrap_execution_payload_storage(\n        &self,\n        keys: &PayloadKeySet,\n        batch_size: i64,\n    ) -> anyhow::Result<()> {\n        anyhow::ensure!(\n            batch_size > 0,\n            \"Execution payload rewrap batch size must be positive\"\n        );\n        self.begin_execution_payload_rewrap(keys).await?;\n\n        loop {\n            if self\n                .rewrap_execution_payload_batch(keys, batch_size)\n                .await?\n            {\n                return Ok(());\n            }\n        }\n    }\n\n    async fn begin_execution_payload_rewrap(&self, keys: &PayloadKeySet) -> anyhow::Result<()> {\n        let mut transaction = self\n            .pool","sourceCodeStart":5298,"sourceCodeEnd":5334,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L5298-L5334","documentation":"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.","triggerScenarios":"Calling rewrap_execution_payload_storage(keys, batch_size) with batch_size <= 0 (e.g. 0, a negative value, or an uninitialized/default i64).","commonSituations":"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).","solutions":["Pass a positive batch size, e.g. 500 or 1000 rows per batch.","Fix the config source so an unset value falls back to a sane default instead of 0.","Check casts/widening from unsigned types so negative or zero values cannot reach the call."],"exampleFix":"// before\nlet batch_size: i64 = config.rewrap_batch_size.unwrap_or(0) as i64;\n// after\nlet batch_size: i64 = config.rewrap_batch_size.unwrap_or(500).max(1) as i64;","handlingStrategy":"validation","validationCode":"let batch_size = config.rewrap_batch_size.unwrap_or(500);\nif batch_size <= 0 {\n    return Err(anyhow!(\"rewrap batch size must be positive, got {batch_size}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use unsigned types (u32) for batch-size config and convert at the boundary.","Provide a non-zero default for unset config values.","Validate operator config at load time, before the rewrap job starts."],"tags":["database","argument-validation","rust"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}