{"record":{"id":"5b63b34382f1ac8d","repo":"nautechsystems/nautilus_trader","slug":"failed-to-serialize-signdoc-e","errorCode":null,"errorMessage":"Failed to serialize SignDoc: {e}","messagePattern":"Failed to serialize SignDoc: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/common/credential.rs","lineNumber":199,"sourceCode":"    /// Returns an error if the address cannot be parsed as a valid account ID.\n    pub fn account_id(&self) -> anyhow::Result<AccountId> {\n        self.address\n            .parse()\n            .map_err(|e| anyhow::anyhow!(\"Failed to parse account ID: {e}\"))\n    }\n\n    /// Signs a transaction SignDoc.\n    ///\n    /// This produces the signature bytes that will be included in the transaction.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if SignDoc serialization or signing fails.\n    pub fn sign(&self, sign_doc: &SignDoc) -> anyhow::Result<Vec<u8>> {\n        let sign_bytes = sign_doc\n            .clone()\n            .into_bytes()\n            .map_err(|e| anyhow::anyhow!(\"Failed to serialize SignDoc: {e}\"))?;\n\n        let signature = self\n            .signing_key\n            .sign(&sign_bytes)\n            .map_err(|e| anyhow::anyhow!(\"Failed to sign: {e}\"))?;\n        Ok(signature.to_bytes().to_vec())\n    }\n\n    /// Signs raw message bytes.\n    ///\n    /// Used for custom signing operations outside of standard transaction flow.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if signing fails.\n    pub fn sign_bytes(&self, message: &[u8]) -> anyhow::Result<Vec<u8>> {\n        let signature = self\n            .signing_key","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/common/credential.rs#L181-L217","documentation":"Signing failure in the dYdX credential's sign: serializing the SignDoc to the canonical bytes to be signed failed, so no signature could be produced; the serialization error is embedded in the message.","triggerScenarios":"Calling sign(&SignDoc) where the SignDoc cannot be encoded — e.g. a SignDoc built with malformed/empty fields that the protobuf encoder rejects, or a messages/body combination that fails encoding.","commonSituations":"Constructing SignDoc manually with missing account number, chain-id, or malformed tx messages; protobuf schema mismatch after upgrading the dydx proto crate.","solutions":["Verify the SignDoc fields (chain_id, account_number, account_sequence, messages) are populated and valid before signing","Build SignDoc through the library's tx-building helpers rather than hand-assembling fields","Check dydx proto dependency versions for schema compatibility"],"exampleFix":"// before\nlet sign_doc = SignDoc { /* partially filled */ };\nlet sig = creds.sign(&sign_doc)?;\n// after\nlet sign_doc = SignDocBuilder::new()\n    .chain_id(\"dydx-mainnet-1\")\n    .account_number(acct)\n    .account_sequence(seq)\n    .messages(vec![msg])\n    .build()?;\nlet sig = creds.sign(&sign_doc)?;","handlingStrategy":"validation","validationCode":"assert!(!sign_doc.chain_id.is_empty(), \"chain_id required\");\nassert!(!sign_doc.messages.is_empty(), \"at least one message required\");","typeGuard":null,"tryCatchPattern":"let sig = creds.sign(&sign_doc).map_err(|e| { eprintln!(\"SignDoc serialization failed — verify chain_id, account_number and messages\"); e })?;","preventionTips":["Build SignDoc via the library's builder/helpers instead of hand-assembly","Populate chain_id, account_number, and account_sequence before signing","Keep dydx proto crate versions in sync across the workspace"],"tags":["rust","crypto","protobuf","signing"],"backgroundTag":"json-marshal-failed","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"}