{"record":{"id":"5d182c2be73d3a89","repo":"nautechsystems/nautilus_trader","slug":"synthetic-synthetic-id-does-not-exist","errorCode":null,"errorMessage":"`synthetic` {synthetic.id} does not exist","messagePattern":"`synthetic` (.+?) does not exist","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/actor/data_actor.rs","lineNumber":4326,"sourceCode":"        if cache.borrow().synthetic(&synthetic.id).is_some() {\n            anyhow::bail!(\"`synthetic` {} already exists\", synthetic.id);\n        }\n        cache.borrow_mut().add_synthetic(synthetic)\n    }\n\n    /// Updates the `synthetic` instrument in the cache, replacing the existing entry.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if no synthetic with the same ID already exists, or if the\n    /// backing cache fails to persist the replacement. Panics if the actor is not\n    /// registered with a trader. // panics-doc-ok\n    pub fn update_synthetic(&self, synthetic: SyntheticInstrument) -> anyhow::Result<()> {\n        self.check_registered();\n\n        let cache = self.cache_rc();\n        if cache.borrow().synthetic(&synthetic.id).is_none() {\n            anyhow::bail!(\"`synthetic` {} does not exist\", synthetic.id);\n        }\n        cache.borrow_mut().add_synthetic(synthetic)\n    }\n\n    /// Subscribes the actor to data.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the actor is not properly registered.\n    pub fn subscribe_data(\n        &mut self,\n        handler: ShareableMessageHandler,\n        data_type: DataType,\n        client_id: Option<ClientId>,\n        params: Option<Params>,\n    ) {\n        assert!(\n            self.is_properly_registered(),","sourceCodeStart":4308,"sourceCodeEnd":4344,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/actor/data_actor.rs#L4308-L4344","documentation":"`DataActor::update_synthetic` requires the synthetic to already exist in the cache; it performs an update by re-adding. If no instrument with that `synthetic.id` is cached, updating is meaningless and the call bails.","triggerScenarios":"Calling `actor.update_synthetic(synthetic)` when `cache.synthetic(&synthetic.id)` is None — the synthetic was never added, was created with a typo'd ID, or was removed earlier.","commonSituations":"Typo in the synthetic ID; updating in a fresh process/cache where the synthetic was never registered; config change renamed the ID so the update targets a nonexistent key.","solutions":["Add the synthetic first with `add_synthetic`, then update","Verify the synthetic ID matches the one previously added","Ensure the same cache database is in use as when the synthetic was added"],"exampleFix":"// before\nactor.update_synthetic(spread)?; // may bail if never added\n// after\nif actor.cache_rc().borrow().synthetic(&spread.id).is_some() {\n    actor.update_synthetic(spread)?;\n} else {\n    actor.add_synthetic(spread)?;\n}","handlingStrategy":"validation","validationCode":"if cache.borrow().synthetic(&id).is_none() {\n    actor.add_synthetic(synthetic)?; // add instead of update\n} else {\n    actor.update_synthetic(synthetic)?;\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = actor.update_synthetic(synthetic.clone()) {\n    if e.to_string().contains(\"does not exist\") {\n        actor.add_synthetic(synthetic)?;\n    } else { return Err(e); }\n}","preventionTips":["Only update synthetics that were previously added","Verify IDs match those used at add time","Use add-then-update flows in fresh cache environments"],"tags":["cache","synthetic","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}