{"record":{"id":"017c8645a49f75bd","repo":"nautechsystems/nautilus_trader","slug":"unsupported-cache-snapshot-blob-ref-blob-ref","errorCode":null,"errorMessage":"unsupported cache snapshot blob_ref {blob_ref}","messagePattern":"unsupported cache snapshot blob_ref (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/cache/position.rs","lineNumber":446,"sourceCode":"\n    /// Gets position snapshot IDs for the `instrument_id`.\n    #[must_use]\n    pub fn position_snapshot_ids(&self, instrument_id: &InstrumentId) -> AHashSet<PositionId> {\n        self.position_snapshots\n            .keys()\n            .filter(|position_id| {\n                self.positions\n                    .get(position_id)\n                    .is_some_and(|position| position.borrow().instrument_id == *instrument_id)\n            })\n            .copied()\n            .collect()\n    }\n}\n\nfn parse_position_snapshot_blob_ref(blob_ref: &str) -> anyhow::Result<(PositionId, usize)> {\n    let Some(rest) = blob_ref.strip_prefix(\"cache://position-snapshots/\") else {\n        anyhow::bail!(\"unsupported cache snapshot blob_ref {blob_ref}\");\n    };\n\n    let Some((position_id, snapshot_index)) = rest.rsplit_once('/') else {\n        anyhow::bail!(\"malformed position snapshot blob_ref {blob_ref}\");\n    };\n\n    if position_id.is_empty() {\n        anyhow::bail!(\"position snapshot blob_ref {blob_ref} has empty position id\");\n    }\n\n    let snapshot_index = snapshot_index.parse::<usize>().map_err(|e| {\n        anyhow::anyhow!(\"position snapshot blob_ref {blob_ref} has invalid frame index: {e}\")\n    })?;\n\n    Ok((PositionId::new(position_id), snapshot_index))\n}\n\nfn decode_position_snapshot_blob(","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/cache/position.rs#L428-L464","documentation":"parse_position_snapshot_blob_ref parses blob references of the exact form 'cache://position-snapshots/<position_id>/<frame_index>'. This error is raised when the string does not start with the required 'cache://position-snapshots/' prefix, meaning the blob_ref is not a position-snapshot reference the cache can resolve.","triggerScenarios":"Calling position_snapshot_frame or restore_snapshot_blob with a blob_ref that has a different scheme/path (e.g. 'cache://orders/...', a bare ID, a different cache collection name, or a truncated/corrupted string).","commonSituations":"Storing blob_refs from one cache collection and replaying them against the position snapshot API; hand-building blob_ref strings with a typo in the prefix; loading refs written by another library version that used a different path scheme.","solutions":["Ensure the blob_ref starts exactly with 'cache://position-snapshots/'","Only pass blob_refs that were produced by the position snapshot writer (position_snapshot_frame), don't hand-craft them","Check for truncation or string corruption when persisting/transporting blob_refs"],"exampleFix":"// before\nlet blob_ref = format!(\"cache://positions/{position_id}/{index}\");\n// after\nlet blob_ref = format!(\"cache://position-snapshots/{position_id}/{index}\");","handlingStrategy":"validation","validationCode":"fn is_position_snapshot_ref(blob_ref: &str) -> bool {\n    blob_ref.starts_with(\"cache://position-snapshots/\")\n}\nassert!(is_position_snapshot_ref(&blob_ref), \"bad blob_ref: {blob_ref}\");","typeGuard":"fn as_position_snapshot_ref(blob_ref: &str) -> Option<&str> {\n    blob_ref.strip_prefix(\"cache://position-snapshots/\")\n}","tryCatchPattern":"match cache.restore_snapshot_blob(blob_ref, blob) {\n    Ok(p) => /* use p */,\n    Err(e) if e.to_string().contains(\"unsupported cache snapshot blob_ref\") => /* fix ref scheme */,\n    Err(e) => return Err(e),\n}","preventionTips":["Always obtain blob_refs from the cache writer API, never hand-format them","Centralize the 'cache://position-snapshots/' prefix in one constant used by writers and readers"],"tags":["cache","blob-ref","invalid-argument-format","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"}