{"record":{"id":"0c0a0dd45cc5b3fa","repo":"nautechsystems/nautilus_trader","slug":"krakenhttperror-cloned-per-order-batch-failure-0c0a0d","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/spot/client.rs","lineNumber":2838,"sourceCode":"                // AddOrderBatch returns result items in request order, so exact cardinality makes\n                // positional correlation unambiguous.\n                Ok(response) if response.orders.len() == batch.len() => {\n                    for ((idx, _), order) in batch.iter().zip(response.orders) {\n                        results[*idx] = Some(Ok(order));\n                    }\n                }\n                Ok(response) => {\n                    for (idx, _) in batch {\n                        results[*idx] = Some(Err(KrakenBatchOrderError::ResponseCount {\n                            expected: batch.len(),\n                            actual: response.orders.len(),\n                        }\n                        .into()));\n                    }\n                }\n                Err(e) => {\n                    for (idx, _) in batch {\n                        results[*idx] = Some(Err(anyhow::Error::new(e.clone())));\n                    }\n\n                    for later_batch in &batches[batch_index + 1..] {\n                        for (idx, _) in later_batch {\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":2820,"sourceCodeEnd":2856,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/http/spot/client.rs#L2820-L2856","documentation":"Same pattern as the Kraken Futures client: in the Kraken Spot batch submit path, if a batch HTTP call fails, every order in that batch receives a clone of the KrakenHttpError, and every later batch is marked NotAttempted before breaking out of the loop.","triggerScenarios":"submit_orders_batch() where inner.submit_orders_batch(batch) returns Err — HTTP/network failure, auth rejection, or rate limit on Kraken Spot's batch order endpoint.","commonSituations":"Burst order submission during outages or rate-limit windows, invalid/expired API keys, or connectivity loss between the client and Kraken Spot.","solutions":["Unwrap the cloned KrakenHttpError to read status code and message.","Retry failed and NotAttempted batches with exponential backoff, respecting Retry-After on 429.","Validate API credentials and endpoint permissions up front.","Keep batch sizes small so a single failure doesn't mark many orders NotAttempted."],"exampleFix":"// before\nlet results = client.submit_orders_batch(orders).await; // later batches NotAttempted after one failure\n// after\nfor batch in orders.chunks(15) { match client.submit_orders_batch(batch.to_vec()).await { /* per-batch retry */ } }","handlingStrategy":"retry","validationCode":"// ensure each batch is within Kraken spot limits before send\nassert!(batch.len() <= MAX_BATCH_SIZE);","typeGuard":null,"tryCatchPattern":"for r in client.submit_orders_batch(orders).await {\n    if let Err(e) = r {\n        if !format!(\"{e}\").contains(\"NotAttempted\") { /* retry with backoff */ }\n    }\n}","preventionTips":["Split large submissions into small independent batches","Use idempotent client order ids so retries are safe","Respect rate limits; back off on 429","Pre-validate credentials and order parameters"],"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"}