{"record":{"id":"0756547f644ec8fb","repo":"nautechsystems/nautilus_trader","slug":"conflicting-rtds-twap-observation-topic-symbol","errorCode":null,"errorMessage":"conflicting RTDS TWAP observation topic={} symbol={} timestamp_ms={} prior={} received={}","messagePattern":"conflicting RTDS TWAP observation topic=(.+?) symbol=(.+?) timestamp_ms=(.+?) prior=(.+?) received=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/rtds.rs","lineNumber":1574,"sourceCode":"            .values()\n            .map(|tracked| tracked.data_type.clone())\n            .collect::<Vec<_>>();\n\n        if data_types.is_empty() {\n            return Ok(None);\n        }\n\n        if let Some(previous) = subscription.last_twap_fingerprint {\n            if timestamp_ms < previous.timestamp_ms {\n                return Ok(None);\n            }\n\n            if timestamp_ms == previous.timestamp_ms {\n                if value == previous.value {\n                    return Ok(None);\n                }\n\n                anyhow::bail!(\n                    concat!(\n                        \"conflicting RTDS TWAP observation topic={} symbol={} \",\n                        \"timestamp_ms={} prior={} received={}\",\n                    ),\n                    topic.as_str(),\n                    symbol_lower,\n                    previous.timestamp_ms,\n                    previous.value,\n                    value,\n                );\n            }\n        }\n\n        subscription.last_twap_fingerprint = Some(TwapReplayFingerprint {\n            timestamp_ms,\n            value,\n        });\n        Ok(Some(data_types))","sourceCodeStart":1556,"sourceCodeEnd":1592,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/rtds.rs#L1556-L1592","documentation":"The RTDS (real-time data stream) TWAP feed tracks one observation per (topic, symbol) keyed by timestamp_ms. A new observation arrived with the same timestamp as the previously stored one but a different value, which would silently overwrite or duplicate an observation; the library treats this as a data-integrity violation and aborts processing that message.","triggerScenarios":"Two distinct TWAP values arrive on the same RTDS topic for the same symbol with an identical millisecond timestamp (duplicate/conflicting upstream event, replayed frame, or interleaved producers). Only exact duplicate values return Ok(None); value difference triggers the bail.","commonSituations":"Upstream RTDS re-sending a corrected observation with the same timestamp; clock granularity too coarse on the venue; two subscriptions or duplicated subscription filters delivering the same event twice through one handler.","solutions":["Inspect the raw RTDS frames for the topic/symbol to see whether the venue is re-publishing corrections and whether a correction channel/metadata is being dropped","Deduplicate upstream connections: ensure only one subscription per topic exists (no duplicated filters or double-subscribe)","If venue legitimately emits corrections, relax the guard to log a warning and replace prior, or key observations by (timestamp_ms, value)","Report/pin the venue feed behavior; if it is a known upstream anomaly, bump accepted timestamps or use a higher-resolution event time"],"exampleFix":"// before\nif value == previous.value {\n    return Ok(None);\n}\nanyhow::bail!(\"conflicting RTDS TWAP observation ... prior={} received={}\", previous.value, value);\n// after\nif value == previous.value {\n    return Ok(None);\n}\ntracing::warn!(\"RTDS TWAP correction topic={} symbol={} ts={} prior={} received={}\", topic.as_str(), symbol_lower, timestamp_ms, previous.value, value);\nreturn Ok(Some(accepted_observation));","handlingStrategy":"validation","validationCode":"if let Some(prev) = tracker.get(&(topic, symbol)) {\n    if prev.timestamp_ms == obs.timestamp_ms && prev.value != obs.value {\n        // decide: drop duplicate or log correction before feeding the API\n        continue;\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Subscribe to each RTDS topic exactly once; avoid duplicated filters","Keep a (topic, symbol) -> last observation map and pre-filter conflicting duplicates","Monitor venue feed for re-published corrections"],"tags":["rust","websocket","data-integrity","polymarket"],"backgroundTag":"internal-invariant-violation","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"}