nautechsystems/nautilus_trader · error · anyhow::Error
Invalid IBOrderTags conditions: {e}
Error message
Invalid IBOrderTags conditions: {e} What it means
apply_ib_order_conditions parses the 'conditions' section of an IBOrderTags JSON payload and converts it into IB order condition objects. When that parsing fails (the inner `e`), the function returns this error, aborting the tag application so no partially-formed conditions reach the ib_order. Conditions control auxiliary IB behaviors such as cancel-on-fill of related orders.
Source
Thrown at crates/adapters/interactive_brokers/src/execution/transform/tags.rs:400
match create_ib_conditions(&Value::Array(conditions_array.clone())) {
Ok(conditions) => {
if conditions.is_empty() {
return Ok(());
}
ib_order.conditions = conditions;
tracing::debug!("Setting {} conditions on order", ib_order.conditions.len());
if let Some(conditions_cancel_order) = tags_obj
.get("conditionsCancelOrder")
.and_then(|v| v.as_bool())
{
ib_order.conditions_cancel_order = conditions_cancel_order;
}
Ok(())
}
Err(e) => Err(anyhow::anyhow!("Invalid IBOrderTags conditions: {e}")),
}
}
fn parse_ib_order_type(value: &str) -> Option<IbOrderType> {
let upper = value.to_ascii_uppercase();
IbOrderType::from_str(value)
.or_else(|_| IbOrderType::from_str(&upper))
.ok()
}
fn parse_ib_tif(value: &str) -> Option<IbTimeInForce> {
let upper = value.to_ascii_uppercase();
IbTimeInForce::from_str(value)
.or_else(|_| IbTimeInForce::from_str(&upper))
.ok()
}
fn apply_non_guaranteed_combo_tag(ib_order: &mut IBOrder, value: &Value) -> anyhow::Result<()> {View on GitHub (pinned to 18893faf8b)
Solutions
- Inspect the inner error `e` in the message to see the exact conditions parse failure.
- Fix the 'conditions' structure in the tags JSON to match the expected IBOrderTags conditions schema (correct keys and value types).
- Serialize conditions programmatically from the IBOrderTags structs instead of hand-writing JSON.
- Keep the tags producer and adapter versions in sync.
Example fix
// before
{"conditions": "use_default"} // wrong type
// after
{"conditions": {"conditions_cancel_order": true}} Defensive patterns
Strategy: validation
Validate before calling
let v: serde_json::Value = serde_json::from_str(tags_json)?;
if let Some(c) = v.get("conditions") {
serde_json::from_value::<IbOrderConditions>(c.clone())?; // fail fast, better error
} Try / catch
match apply_ib_order_tag_json(&mut order, &tags_json) {
Ok(()) => (),
Err(e) if e.to_string().contains("Invalid IBOrderTags conditions") => {
log::error!("malformed conditions in tags payload: {e}");
}
Err(e) => return Err(e),
} Prevention
- Serialize conditions from structs, never hand-write the JSON
- Validate tags JSON against the conditions schema in CI
- Test the full tags payload through apply_ib_order_tag_json before live use
When it happens
Trigger: Calling apply_ib_order_tag_json with a payload whose 'conditions' object/array does not match the expected IBOrderTags conditions schema (missing keys, wrong types, malformed structure), producing inner error `e`.
Common situations: Hand-writing a tags JSON with a misspelled condition key; passing conditions as a string instead of a JSON object; version drift between the tool that emits the tags JSON and the adapter that consumes it.
Understand the failure class
Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.
Related errors
- Invalid IBOrderTags payload: expected a JSON object
- Invalid IBOrderTags field {field}: {value}
- Failed to apply IBOrderTags because IB order JSON is not an
- Unsupported IBOrderTags field: {field}
- Failed to restore IB order JSON after invalid IBOrderTags fi
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/32d152e13bbbc24a.
Report an issue: GitHub.