{"record":{"id":"ef9c754ef0de33b2","repo":"nautechsystems/nautilus_trader","slug":"gamma-scope-filter-key-cannot-be-empty","errorCode":null,"errorMessage":"Gamma {scope} filter '{key}' cannot be empty","messagePattern":"Gamma (.+?) filter '(.+?)' cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/providers.rs","lineNumber":1028,"sourceCode":"    scope: &str,\n    key: &str,\n    value: &str,\n) -> anyhow::Result<Vec<u64>> {\n    parse_gamma_filter_list(scope, key, value)?\n        .into_iter()\n        .map(|item| {\n            item.parse::<u64>().map_err(|e| {\n                anyhow::anyhow!(\n                    \"Gamma {scope} filter '{key}' values must be unsigned integers: {e}\"\n                )\n            })\n        })\n        .collect()\n}\n\nfn parse_gamma_filter_string(scope: &str, key: &str, value: &str) -> anyhow::Result<String> {\n    if value.trim().is_empty() {\n        anyhow::bail!(\"Gamma {scope} filter '{key}' cannot be empty\")\n    }\n    Ok(value.to_string())\n}\n\n/// Resolves a tag slug to a tag ID by querying the Gamma tags endpoint.\npub async fn resolve_tag_slug(\n    client: &PolymarketGammaHttpClient,\n    slug: &str,\n) -> anyhow::Result<u64> {\n    let tags = client.request_tags().await?;\n    let tag_id = tags\n        .iter()\n        .find(|t| t.slug.as_deref() == Some(slug))\n        .map(|t| t.id.as_str())\n        .ok_or_else(|| anyhow::anyhow!(\"Tag slug '{slug}' not found\"))?;\n    tag_id\n        .parse::<u64>()\n        .map_err(|e| anyhow::anyhow!(\"Tag slug '{slug}' returned invalid ID '{tag_id}': {e}\"))","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/providers.rs#L1010-L1046","documentation":"Generic guard in the Polymarket Gamma API filter parser: a filter value that must be a non-empty string was blank or whitespace-only, so the Gamma request would be built with an empty filter clause and is rejected instead.","triggerScenarios":"Passing '' or '   ' for a string filter key (e.g. slug, locale) in build_gamma_params_from_hashmap via query_markets or the instrument loaders.","commonSituations":"Optional config values left empty; env vars set but blank; string defaults of '' used as placeholders then passed through unconditionally.","solutions":["Omit the key from the filter map when the value is empty","Trim and validate the value in the caller before inserting it","Use Option<String> in config and only add the filter when Some and non-empty"],"exampleFix":"// before\nfilters.insert(\"slug\".into(), cfg.slug.clone()); // may be \"\"\n// after\nif !cfg.slug.trim().is_empty() {\n    filters.insert(\"slug\".into(), cfg.slug.clone());\n}","handlingStrategy":"validation","validationCode":"fn add_string_filter(filters: &mut HashMap<String,String>, key: &str, v: &str) {\n    if !v.trim().is_empty() {\n        filters.insert(key.to_string(), v.to_string());\n    }\n}","typeGuard":"fn is_non_blank(v: &str) -> bool { !v.trim().is_empty() }","tryCatchPattern":null,"preventionTips":["Use Option<String> for optional filters and insert only when Some","Trim config/env values at load time","Never use '' as a default for required string filters"],"tags":["rust","validation","filters","parsing"],"backgroundTag":"empty-required-field","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"}