{"record":{"id":"2bbdd127e45c54c4","repo":"nautechsystems/nautilus_trader","slug":"filter-key-contains-a-non-string-value","errorCode":null,"errorMessage":"filter {key:?} contains a non-string value","messagePattern":"filter (.+?) contains a non-string value","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/instruments.rs","lineNumber":100,"sourceCode":"    }\n}\n\nfn filter_values(\n    config: &BinanceInstrumentProviderConfig,\n    key: &str,\n) -> anyhow::Result<Option<AHashSet<String>>> {\n    let Some(value) = config.filters.get(key) else {\n        return Ok(None);\n    };\n\n    let values = match value {\n        serde_json::Value::String(value) => vec![value.as_str()],\n        serde_json::Value::Array(values) => values\n            .iter()\n            .map(|value| {\n                value\n                    .as_str()\n                    .ok_or_else(|| anyhow::anyhow!(\"filter {key:?} contains a non-string value\"))\n            })\n            .collect::<anyhow::Result<Vec<_>>>()?,\n        _ => anyhow::bail!(\"filter {key:?} is not a string or array\"),\n    };\n\n    Ok(Some(\n        values\n            .into_iter()\n            .map(|value| value.trim().to_ascii_uppercase())\n            .collect(),\n    ))\n}\n\nfn matches_filter(values: &Option<AHashSet<String>>, value: &str) -> bool {\n    values.as_ref().is_none_or(|values| contains(values, value))\n}\n\nfn contains(values: &AHashSet<String>, value: &str) -> bool {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/instruments.rs#L82-L118","documentation":"filter_values extracts string values from an exchange filter JSON object. When the value is an array, every element must be a JSON string; this error means at least one array element was a non-string type (number, bool, object, null), which the parser cannot turn into a filter value.","triggerScenarios":"Parsing exchangeInfo filters (e.g. orderTypes-like arrays) where an element is not a string — malformed or unexpected exchange metadata, or custom/synthetic filter JSON fed to the instrument parser.","commonSituations":"Binance changing or extending the exchangeInfo filter schema; mocked/test filter fixtures with numeric values; proxy or caching layers re-serializing strings as numbers.","solutions":["Fix the filter JSON so all array elements are strings.","Update the adapter if Binance changed the filter schema to a non-string representation.","Log the offending filter object to identify which exchange symbol/filter produced the bad value.","Validate test fixtures against the real exchangeInfo response shape."],"exampleFix":"// before\nlet filter = json!({\"orderTypes\": [\"LIMIT\", 1]});\n\n// after\nlet filter = json!({\"orderTypes\": [\"LIMIT\", \"MARKET\"]});","handlingStrategy":"validation","validationCode":"fn all_strings(v: &serde_json::Value) -> bool {\n    v.as_array()\n        .map(|a| a.iter().all(|e| e.is_string()))\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate fixtures against real exchangeInfo responses.","Watch for Binance schema changes in filter fields.","Avoid re-serializing exchange payloads through typed layers that coerce strings to numbers."],"tags":["binance","json","filters","type-mismatch"],"backgroundTag":"unexpected-response-shape","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}