{"record":{"id":"860276f620d22adf","repo":"nautechsystems/nautilus_trader","slug":"invalid-ibordertags-payload-expected-a-json-objec","errorCode":null,"errorMessage":"Invalid IBOrderTags payload: expected a JSON object","messagePattern":"Invalid IBOrderTags payload: expected a JSON object","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/transform/tags.rs","lineNumber":53,"sourceCode":"\n    for tag in tags {\n        let tag_str = tag.as_str();\n        if !tag_str.starts_with(\"IBOrderTags:\") {\n            continue;\n        }\n\n        let json_str = tag_str.trim_start_matches(\"IBOrderTags:\");\n        let tags_obj = serde_json::from_str::<Value>(json_str)\n            .with_context(|| format!(\"Invalid IBOrderTags JSON: {json_str}\"))?;\n        apply_ib_order_tag_json(ib_order, &tags_obj)?;\n    }\n\n    Ok(())\n}\n\nfn apply_ib_order_tag_json(ib_order: &mut IBOrder, tags_obj: &Value) -> anyhow::Result<()> {\n    let Some(tags_map) = tags_obj.as_object() else {\n        anyhow::bail!(\"Invalid IBOrderTags payload: expected a JSON object\");\n    };\n\n    let mut updated_order = ib_order.clone();\n    apply_ib_order_tag_overlay(&mut updated_order, tags_map)?;\n    apply_ib_order_conditions(&mut updated_order, tags_obj)?;\n\n    *ib_order = updated_order;\n    Ok(())\n}\n\nfn apply_ib_order_tag_overlay(\n    ib_order: &mut IBOrder,\n    tags_map: &Map<String, Value>,\n) -> anyhow::Result<()> {\n    let mut order_value = serde_json::to_value(&*ib_order)\n        .context(\"Failed to serialize IB order before applying IBOrderTags\")?;\n\n    for (key, value) in tags_map {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/transform/tags.rs#L35-L71","documentation":"IBOrderTags payloads are expected to be a JSON object (map of IB order field names to values). apply_ib_order_tag_json parses the provided serde_json::Value and bails if it is not a JSON object (e.g. an array, string, or number).","triggerScenarios":"Calling apply_ib_order_tags with a tags payload that parses to a non-object JSON Value, such as '[\"outside_rth\"]', '\"outside_rth\"', or 'null', instead of '{\"outside_rth\": true}'.","commonSituations":"Order tags passed as a JSON array of strings, a bare string from config, or a YAML/JSON scalar misread as tags; also when the tags string decodes to null.","solutions":["Wrap the tags in a JSON object: '{\"outside_rth\": true}' rather than 'outside_rth' or '[...]'\nValidate the payload shape before calling: serde_json::from_str::<serde_json::Map<String, Value>>() and fail fast on error\nCheck where the tags string originates (config file, env var) and fix the encoding there"],"exampleFix":"// before\nlet tags = \"[\\\"outside_rth\\\"]\";\n// after\nlet tags = \"{\\\"outside_rth\\\": true}\";","handlingStrategy":"validation","validationCode":"let v: serde_json::Value = serde_json::from_str(&tags_str)?;\nif !v.is_object() {\n    return Err(anyhow::anyhow!(\"IBOrderTags must be a JSON object\"));\n}","typeGuard":"fn is_tags_object(v: &serde_json::Value) -> bool { v.is_object() }","tryCatchPattern":null,"preventionTips":["Store order tags as JSON objects in config, never bare strings or arrays","Parse and validate tags at config-load time, not at order time","Add a schema example in your config documentation"],"tags":["interactive-brokers","json","validation","rust"],"backgroundTag":"invalid-argument-format","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"}