{"record":{"id":"ab4f07ee3b627acb","repo":"nautechsystems/nautilus_trader","slug":"execution-payload-check-batch-size-must-be-positiv","errorCode":null,"errorMessage":"Execution payload check batch size must be positive","messagePattern":"Execution payload check batch size must be positive","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":5115,"sourceCode":"        batch_size: i64,\n    ) -> anyhow::Result<ExecutionPayloadCheck> {\n        let (check, transaction) = self\n            .inspect_execution_payload_storage(keys, policy, batch_size)\n            .await?;\n        transaction\n            .commit()\n            .await\n            .context(\"failed to complete execution payload check\")?;\n        Ok(check)\n    }\n\n    async fn inspect_execution_payload_storage(\n        &self,\n        keys: Option<&PayloadKeySet>,\n        policy: Option<PayloadPolicy>,\n        batch_size: i64,\n    ) -> anyhow::Result<(ExecutionPayloadCheck, Transaction<'static, Postgres>)> {\n        anyhow::ensure!(\n            batch_size > 0,\n            \"Execution payload check batch size must be positive\"\n        );\n        let mut transaction = self\n            .pool\n            .begin()\n            .await\n            .context(\"failed to start execution payload check\")?;\n        sqlx::query(\"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ\")\n            .execute(&mut *transaction)\n            .await\n            .context(\"failed to stabilize execution payload snapshot\")?;\n        sqlx::query(\"LOCK TABLE execution_transaction_hash IN SHARE MODE\")\n            .execute(&mut *transaction)\n            .await\n            .context(\"failed to stabilize execution payload check\")?;\n        let marker = sqlx::query_scalar::<_, i16>(\n            \"SELECT version FROM execution_schema_version WHERE component = $1\",","sourceCodeStart":5097,"sourceCodeEnd":5133,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L5097-L5133","documentation":"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.","triggerScenarios":"Calling inspect_execution_payload_storage with batch_size = 0 or a negative i64, typically from unvalidated configuration or a default-initialized parameter.","commonSituations":"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.","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"],"exampleFix":"// before\nlet check = storage.inspect_execution_payload_storage(None, None, config.batch_size).await?;\n// after\nlet batch = config.batch_size.max(1);\nlet check = storage.inspect_execution_payload_storage(None, None, batch).await?;","handlingStrategy":"validation","validationCode":"fn valid_batch_size(v: i64) -> bool { v > 0 }","typeGuard":"fn is_positive_batch(v: i64) -> Option<std::num::NonZeroI64> { std::num::NonZeroI64::new(v) }","tryCatchPattern":"match inspect_storage(keys, policy, batch_size).await {\n    Err(e) if e.to_string().contains(\"batch size must be positive\") => inspect_storage(keys, policy, batch_size.max(1)).await,\n    other => other,\n}","preventionTips":["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"],"tags":["validation","argument","configuration"],"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"}