{"record":{"id":"823e2c3e0a1114eb","repo":"nautechsystems/nautilus_trader","slug":"krakenhttperror-cloned-per-order-batch-failure","errorCode":null,"errorMessage":"KrakenHttpError (cloned per-order batch failure)","messagePattern":"KrakenHttpError \\(cloned per-order batch failure\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/http/futures/client.rs","lineNumber":2530,"sourceCode":"                            Some(Some(status)) => Ok(FuturesBatchSubmitItem {\n                                result: response_result,\n                                status,\n                            }),\n                            Some(None) => Err(KrakenBatchOrderError::DuplicateResponse {\n                                key: format!(\"order_tag {}\", item.order_tag),\n                            }\n                            .into()),\n                            None => Err(KrakenBatchOrderError::MissingResponse {\n                                key: format!(\"order_tag {}\", item.order_tag),\n                            }\n                            .into()),\n                        };\n                        results[*idx] = Some(result);\n                    }\n                }\n                Err(e) => {\n                    for (idx, _) in *chunk {\n                        results[*idx] = Some(Err(anyhow::Error::new(e.clone())));\n                    }\n\n                    for later_chunk in &chunks[chunk_index + 1..] {\n                        for (idx, _) in *later_chunk {\n                            results[*idx] = Some(Err(KrakenBatchOrderError::NotAttempted.into()));\n                        }\n                    }\n                    break;\n                }\n            }\n        }\n\n        results\n            .into_iter()\n            .map(|result| result.unwrap_or_else(|| Err(KrakenBatchOrderError::NotAttempted.into())))\n            .collect()\n    }\n","sourceCodeStart":2512,"sourceCodeEnd":2548,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/http/futures/client.rs#L2512-L2548","documentation":"When Kraken Futures submit_orders_batch sends a chunk of orders via the batch endpoint and the HTTP/API call itself fails, every order in that chunk gets the same cloned KrakenHttpError as its per-order result. All subsequent (not-yet-sent) chunks are marked NotAttempted and the loop breaks, so one transport failure fails the whole remaining batch.","triggerScenarios":"submit_orders_batch() where inner.submit_orders_batch(chunk) returns Err — network failure, 4xx/5xx from Kraken, auth error, or rate limiting on the batch endpoint.","commonSituations":"Submitting more than one order in a burst during network instability, expired API credentials (401), or hitting batch endpoint rate limits with large order groups.","solutions":["Inspect the wrapped KrakenHttpError for status/body to identify transport vs API rejection.","Retry the failed chunk after a backoff; orders in later chunks are NotAttempted and safe to resubmit.","Verify Kraken API key/secret validity and permissions before large batch submissions.","Split very large batches to reduce blast radius per chunk; orders are NOT attempted after a chunk fails by design (fail-fast)."],"exampleFix":"// before\nlet results = client.submit_orders_batch(orders).await; // one bad chunk -> all later NotAttempted\n// after\nfor chunk in orders.chunks(10) { let r = client.submit_orders_batch(chunk.to_vec()).await; /* retry per chunk */ }","handlingStrategy":"retry","validationCode":"// Rust: pre-check batch size and credentials before submitting\nassert!(orders.len() <= BATCH_ORDER_LIMIT);\n// verify credentials with a lightweight signed request first","typeGuard":null,"tryCatchPattern":"let results = client.submit_orders_batch(orders).await;\nfor (i, r) in results.iter().enumerate() {\n    if let Err(e) = r {\n        if !format!(\"{e}\").contains(\"NotAttempted\") {\n            // retry single order i after backoff\n        }\n    }\n}","preventionTips":["Keep chunks small to limit blast radius of one failed chunk","Treat NotAttempted orders as safe to resubmit; failed-chunk orders need idempotency keys","Backoff on 429 and honor Retry-After","Verify API key permissions before batch trading"],"tags":["rust","kraken","batch-order","http"],"backgroundTag":"http-error-response","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"}