{"record":{"id":"dac3fb3e2b5f5b82","repo":"nautechsystems/nautilus_trader","slug":"payload-rollback-requires-an-active-payload-key","errorCode":null,"errorMessage":"Payload rollback requires an active payload key","messagePattern":"Payload rollback requires an active payload key","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":919,"sourceCode":"            .rewrap_execution_payload_storage(&keys, batch_size)\n            .await\n    }\n\n    /// Restores authenticated plaintext payloads and removes protection from this database.\n    ///\n    /// This incident-only operation is resumable. Keep the complete key set configured until it\n    /// succeeds and the unprotected database passes a full payload check.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the client is connected, storage is not protected, required keys are\n    /// unavailable, or any bounded rollback batch fails authentication.\n    pub async fn rollback_payload_storage(&self, batch_size: usize) -> anyhow::Result<()> {\n        let batch_size = validate_payload_operation_batch_size(batch_size)?;\n        let database = self.payload_operation_database().await?;\n        let keys = self\n            .load_payload_keys()?\n            .ok_or_else(|| anyhow::anyhow!(\"Payload rollback requires an active payload key\"))?;\n        database\n            .rollback_execution_payload_storage(&keys, batch_size)\n            .await\n    }\n\n    async fn payload_operation_database(&self) -> anyhow::Result<BlockchainCacheDatabase> {\n        anyhow::ensure!(\n            !self.core.is_connected(),\n            \"Disconnect the execution client before payload storage operations\"\n        );\n\n        if let Some(database) = &self.cache.database {\n            return Ok(database.clone());\n        }\n        let options = self\n            .config\n            .postgres_cache_database_config\n            .as_ref()","sourceCodeStart":901,"sourceCodeEnd":937,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L901-L937","documentation":"rollback_payload_storage() decrypts authenticated plaintext payloads and removes protection, requiring the active payload key set to authenticate the stored ciphertext. When load_payload_keys() returns None the rollback cannot proceed and the client refuses the operation rather than leaving the storage in a half-protected state.","triggerScenarios":"Calling client.rollback_payload_storage(batch_size) when no payload keys were loaded (never protected, keys cleared, or key store unavailable).","commonSituations":"Attempting rollback on a database that was never protected; running rollback from a client instance whose connect sequence did not initialize keys; key store misconfiguration after redeploy.","solutions":["Initialize keys first with protect_payload_storage(), or load them via the normal connect flow, then rollback.","Use check_payload_storage() to confirm keys exist and protection state before rolling back.","Fix key store configuration so load_payload_keys() resolves the persisted keys.","If the storage was never protected, no rollback is needed — skip the call."],"exampleFix":"// before\nclient.rollback_payload_storage(500).await?;\n// after\nanyhow::ensure!(\n    client.check_payload_storage().await?.has_keys,\n    \"initialize keys before rollback\"\n);\nclient.rollback_payload_storage(500).await?;","handlingStrategy":"validation","validationCode":"let status = client.check_payload_storage().await?;\nanyhow::ensure!(status.has_keys, \"payload storage has no keys; nothing to rollback\");\nclient.rollback_payload_storage(batch_size).await?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only roll back databases previously protected.","Check protection state via check_payload_storage() before rollback.","Keep key store configuration stable across deploys."],"tags":["rust","encryption","payload-storage","missing-state"],"backgroundTag":"missing-required-config-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"}