{"record":{"id":"25b08809ffc5e25e","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-amend-order-params-e","errorCode":null,"errorMessage":"Failed to build amend order params: {e}","messagePattern":"Failed to build amend order params: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/http/spot/client.rs","lineNumber":2909,"sourceCode":"        } else if let Some(ref id) = cl_ord_id {\n            builder.cl_ord_id(id.clone());\n        }\n\n        if let Some(qty) = quantity {\n            builder.order_qty(qty.to_string());\n        }\n\n        if let Some(p) = price {\n            builder.limit_price(p.to_string());\n        }\n\n        if let Some(tp) = trigger_price {\n            builder.trigger_price(tp.to_string());\n        }\n\n        let params = builder\n            .build()\n            .map_err(|e| anyhow::anyhow!(\"Failed to build amend order params: {e}\"))?;\n\n        let _response = self.inner.amend_order(&params).await?;\n\n        // AmendOrder modifies in-place, so the order keeps its original ID\n        let order_id = venue_order_id.ok_or(KrakenModifyOrderError::MissingOrderId)?;\n\n        Ok(order_id)\n    }\n\n    /// Cancels an order on the Kraken Spot exchange.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - Credentials are missing.\n    /// - Neither client_order_id nor venue_order_id is provided.\n    /// - The request fails.\n    /// - The order cancellation is rejected.","sourceCodeStart":2891,"sourceCodeEnd":2927,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/http/spot/client.rs#L2891-L2927","documentation":"The amend-order flow builds a Kraken `AmendOrderParams` via a builder with validation. If the combination of fields (order id, quantity, price, trigger price, etc.) is invalid per the builder's checks, `build()` fails and the adapter wraps it in this anyhow error before any HTTP call is made.","triggerScenarios":"Calling amend-order with an invalid parameter combination: e.g. both a modify quantity and price that violate builder invariants, empty required identifiers, malformed price/quantity strings, or mutually exclusive fields set together.","commonSituations":"Strategy code amending an order with a computed price that formats to an invalid string (NaN/zero precision); passing both `venue_order_id` and client order id in a way the builder rejects; amend requests constructed from partially-filled order state with invalid sizes.","solutions":["Read the inner `{e}` message; it names the exact builder validation that failed.","Ensure exactly one valid order identifier is supplied and it is non-empty.","Validate quantity/price/trigger-price values are positive and correctly formatted before calling amend.","Use values sourced from the original order report (precision-correct Price/Quantity types converted with `to_string()`)."],"exampleFix":"// before\nbuilder.quantity(\"0\"); // invalid qty\n// after\nbuilder.quantity(order.quantity().to_string());","handlingStrategy":"validation","validationCode":"fn validate_amend(venue_order_id: Option<&str>, qty: Option<Decimal>, price: Option<Decimal>) -> Result<(), String> {\n    if venue_order_id.map_or(true, |s| s.is_empty()) {\n        return Err(\"amend requires non-empty venue order id\".into());\n    }\n    if qty.map_or(false, |q| q <= Decimal::ZERO) { return Err(\"amend qty must be positive\".into()); }\n    if price.map_or(false, |p| p <= Decimal::ZERO) { return Err(\"amend price must be positive\".into()); }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match client.amend_order(req).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"Failed to build amend order params\") => {\n        log::error!(\"invalid amend request {:?}: {e}\", req);\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Source amend values from the original order report to guarantee valid formats","Never amend orders that lack a venue order id","Validate quantities/prices are positive and precision-correct before calling amend"],"tags":["order-amend","params-builder","validation","kraken"],"backgroundTag":"schema-validation-failed","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"}