{"record":{"id":"43d2a1e7b5563459","repo":"nautechsystems/nautilus_trader","slug":"failed-to-serialize-the-deployment-manifest","errorCode":null,"errorMessage":"Failed to serialize the deployment manifest","messagePattern":"Failed to serialize the deployment manifest","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/verification.rs","lineNumber":1251,"sourceCode":"    );\n    let manifest_digest = B256::from_str(&config.manifest_digest).map_err(|_| {\n        anyhow::anyhow!(\"Deployment manifest digest must contain 32 hexadecimal bytes\")\n    })?;\n    anyhow::ensure!(\n        manifest_digest != B256::ZERO,\n        \"Deployment manifest digest must be nonzero\"\n    );\n    let manifest = &config.deployment_manifest;\n    anyhow::ensure!(\n        manifest.version == config.manifest_version,\n        \"Deployment manifest version does not match its configured identity\"\n    );\n    anyhow::ensure!(\n        manifest.chain_id == anchor.chain_id && manifest.chain_name == anchor.chain_name,\n        \"Deployment manifest chain identity does not match the chain anchor\"\n    );\n    let canonical_manifest = serde_json::to_vec(manifest)\n        .map_err(|_| anyhow::anyhow!(\"Failed to serialize the deployment manifest\"))?;\n    anyhow::ensure!(\n        keccak256(canonical_manifest) == manifest_digest,\n        \"Deployment manifest digest does not match its canonical content\"\n    );\n    anyhow::ensure!(\n        !manifest.contracts.is_empty() && !manifest.tokens.is_empty() && !manifest.pools.is_empty(),\n        \"Deployment manifest contracts, tokens, and pools are required\"\n    );\n    let mut contract_addresses = HashSet::new();\n    let mut roles = HashSet::new();\n\n    for contract in &manifest.contracts {\n        let address = Address::from_str(&contract.address)\n            .map_err(|_| anyhow::anyhow!(\"Deployment manifest contains an invalid address\"))?;\n        anyhow::ensure!(\n            contract_addresses.insert(address),\n            \"Deployment manifest contains a duplicate contract address\"\n        );","sourceCodeStart":1233,"sourceCodeEnd":1269,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/verification.rs#L1233-L1269","documentation":"The validator serializes the deployment manifest to canonical JSON bytes with serde_json::to_vec in order to hash them with keccak256. If serialization fails (e.g. a map key type that cannot serialize, or a poisoned/invalid value), the library cannot form the canonical commitment and raises this error. In practice this indicates a corrupted or improperly typed manifest value rather than a network issue.","triggerScenarios":"serde_json::to_vec(manifest) returning Err while validating `config.deployment_manifest` — typically a non-string map key (e.g. HashMap with B256/address keys) or a custom serializer failure.","commonSituations":"A manifest struct field changed to a type serde_json cannot serialize canonically; deserialized input carrying values that fail round-trip serialization; feature-flagged serde attributes altering serialization support.","solutions":["Ensure all manifest fields use JSON-serializable types (string-keyed maps, Decimal/bytes represented as hex strings).","Round-trip the manifest through serde_json locally to reproduce and locate the failing field.","Pin the serde/serde_json versions used to build the manifest to those used by this crate."],"exampleFix":"// before\ncontracts: HashMap<B256, ContractEntry>,   // non-string keys break serde_json\n// after\ncontracts: BTreeMap<String, ContractEntry>, // hex-string keys, deterministic order","handlingStrategy":"validation","validationCode":"let bytes = serde_json::to_vec(&config.deployment_manifest)\n    .expect(\"manifest must serialize canonically; check for non-string map keys or unsupported types\");\nlet digest = keccak256(&bytes);\nassert_eq!(digest.to_string(), config.manifest_digest);","typeGuard":null,"tryCatchPattern":"match serde_json::to_vec(&config.deployment_manifest) {\n    Ok(bytes) => { /* proceed with keccak256(&bytes) */ }\n    Err(e) => eprintln!(\"manifest serialization failed: {e}; fix manifest field types\"),\n}","preventionTips":["Use string-keyed, ordered maps (BTreeMap<String, _>) in the manifest so serialization is canonical.","Round-trip the manifest through serde_json in tests to catch serializer regressions.","Keep serde/serde_json versions aligned between the manifest generator and this crate."],"tags":["serialization","json","blockchain"],"backgroundTag":"json-serialization-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"}