{"record":{"id":"8894a81e892457c4","repo":"nautechsystems/nautilus_trader","slug":"empty-payload-for-delete-key","errorCode":null,"errorMessage":"Empty `payload` for `delete` '{key}'","messagePattern":"Empty `payload` for `delete` '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/redis/cache.rs","lineNumber":1082,"sourceCode":"        value.is_some()\n    );\n\n    match collection {\n        INDEX => delete_from_index(pipe, key, value),\n        ORDERS | POSITIONS | ACCOUNTS | ACTORS | STRATEGIES => {\n            delete_string(pipe, key);\n            Ok(())\n        }\n        _ => anyhow::bail!(\"Unsupported operation: `delete` for collection '{collection}'\"),\n    }\n}\n\nfn delete_from_index(\n    pipe: &mut Pipeline,\n    key: &str,\n    value: Option<Vec<Bytes>>,\n) -> anyhow::Result<()> {\n    let value = value.ok_or_else(|| anyhow::anyhow!(\"Empty `payload` for `delete` '{key}'\"))?;\n    let index_key = get_index_key(key)?;\n\n    match index_key {\n        INDEX_ORDER_IDS\n        | INDEX_ORDERS\n        | INDEX_ORDERS_OPEN\n        | INDEX_ORDERS_CLOSED\n        | INDEX_ORDERS_EMULATED\n        | INDEX_ORDERS_INFLIGHT\n        | INDEX_POSITIONS\n        | INDEX_POSITIONS_OPEN\n        | INDEX_POSITIONS_CLOSED => {\n            remove_from_set(pipe, key, value[0].as_ref());\n            Ok(())\n        }\n        INDEX_ORDER_POSITION | INDEX_ORDER_CLIENT => {\n            remove_from_hash(pipe, key, value[0].as_ref());\n            Ok(())","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/redis/cache.rs#L1064-L1100","documentation":"delete_from_index removes a key's value from a set/hash index during a Redis pipeline delete. For set indexes a payload (the member value, e.g. the order or position id bytes) is required; if the caller passes None payload, this error fires. It is an internal invariant: index deletions must always carry the member to remove.","triggerScenarios":"A delete operation whose key maps to an index (INDEX_ORDER_IDS, INDEX_ORDERS, INDEX_ORDERS_OPEN, etc.) is issued without a payload — i.e. DatabaseCommand::new(Delete, index_key, None) reaches the pipeline builder.","commonSituations":"Usually triggered by internal code paths or custom integrations that build delete commands manually and omit the payload; not normally hit by end users through delete_order/delete_position, which always supply payloads.","solutions":["If you call the cache delete API directly, always provide Some(vec![member_bytes]) as the payload when deleting from an index key.","Check any custom adapter code that constructs DatabaseCommand objects for Delete operations and ensure payloads are set for index keys.","Verify the key actually denotes an index; plain record deletes (orders/positions) use None payload legitimately and skip this path.","Upgrade nautilus_trader if this arises from stock delete_order/delete_position — it would indicate an internal bug."],"exampleFix":"// before\nlet op = DatabaseCommand::new(DatabaseOperation::Delete, index_key, None);\n// after\nlet op = DatabaseCommand::new(DatabaseOperation::Delete, index_key, Some(vec![member_id_bytes.clone()]));","handlingStrategy":"validation","validationCode":"// ensure index deletes always carry a payload\nassert!(payload.is_some(), \"index delete requires member payload\");","typeGuard":"fn has_payload(p: &Option<Vec<Bytes>>) -> bool { p.as_ref().map_or(false, |v| !v.is_empty()) }","tryCatchPattern":null,"preventionTips":["Always pass Some(vec![member_bytes]) when deleting from an index key.","Reserve None payloads for record keys, not index keys.","Review custom DatabaseCommand construction code for missing payloads."],"tags":["rust","redis","invariant","payload"],"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"}