{"record":{"id":"3b5f070d09e8f62d","repo":"diem/diem","slug":"error-de-serializing-0-1","errorCode":null,"errorMessage":"Error (de)serializing '{0}': {1}","messagePattern":"Error \\(de\\)serializing '(.+?)': (.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/management/src/error.rs","lineNumber":20,"sourceCode":"// SPDX-License-Identifier: Apache-2.0\n\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum Error {\n    #[error(\"Invalid key value found in backend: {0}\")]\n    BackendInvalidKeyValue(String),\n    #[error(\"Backend is missing the backend key\")]\n    BackendMissingBackendKey,\n    #[error(\"Backend parsing error: {0}\")]\n    BackendParsingError(String),\n    #[error(\"Invalid arguments: {0}\")]\n    CommandArgumentError(String),\n    #[error(\"Unable to load config: {0}\")]\n    ConfigError(String),\n    #[error(\"Error accessing '{0}': {1}\")]\n    IO(String, #[source] std::io::Error),\n    #[error(\"Error (de)serializing '{0}': {1}\")]\n    BCS(String, #[source] bcs::Error),\n    #[error(\"Failed to read '{0}' from JSON-RPC: {1}\")]\n    JsonRpcReadError(&'static str, String),\n    #[error(\"Failed to write '{0}' from JSON-RPC: {1}\")]\n    JsonRpcWriteError(&'static str, String),\n    #[error(\"Unable to decode network address: {0}\")]\n    NetworkAddressDecodeError(String),\n    #[error(\"{0} storage unavailable, please check your configuration: {1}\")]\n    StorageUnavailable(&'static str, String),\n    #[error(\"Failed to read '{1}' from {0} storage: {2}\")]\n    StorageReadError(&'static str, &'static str, String),\n    #[error(\"Failed to sign '{1}' with '{2}' using {0} storage: {2}\")]\n    StorageSigningError(&'static str, &'static str, &'static str, String),\n    #[error(\"Failed to write '{1}' to {0} storage: {2}\")]\n    StorageWriteError(&'static str, &'static str, String),\n    #[error(\"{0} timed out: {1}\")]\n    Timeout(&'static str, String),\n    #[error(\"Unable to parse '{0}': error: {1}\")]","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/config/management/src/error.rs#L2-L38","documentation":"This is the BCS variant of the error enum in config/management/src/error.rs. It wraps bcs::Error (via #[source]) and is thrown when (de)serializing config data with the BCS codec fails — typically because the bytes on disk or over the wire do not match the expected Rust type layout. The first argument labels what was being (de)serialized.","triggerScenarios":"Loading a BCS-encoded file (e.g. a serialized keystore or persisted config) whose bytes are corrupt, truncated, or were written by a different struct definition; serializing a struct containing types BCS cannot encode (e.g. non-fixed-size floats or maps without deterministic ordering).","commonSituations":"Manual edits or corruption of binary config artifacts, upgrading the node/client so the struct layout changed while old BCS blobs remain on disk, or mixing versions in shared config directories.","solutions":["Delete and regenerate the corrupt binary artifact (keystore/config) from source of truth","Confirm producer and consumer use the same struct definition / library version","If the format changed intentionally, migrate or re-encode the data rather than loading raw BCS bytes","Keep binary config files out of hand-editing; use the CLI/JSON config instead"],"exampleFix":"// before\nlet keystore: FileBasedKeystore = bcs::from_bytes(&stale_bytes)?; // BCS mismatch\n// after\n// regenerate from the source of truth instead of loading incompatible bytes\nlet keystore = FileBasedKeystore::new(&keystore_path)?;","handlingStrategy":"try-catch","validationCode":"fn looks_like_bcs_artifact(bytes: &[u8]) -> bool {\n    !bytes.is_empty() && !bytes.starts_with(b\"{\") // reject JSON hand-edited files\n}","typeGuard":null,"tryCatchPattern":"match bcs::from_bytes::<MyConfig>(&bytes) {\n    Ok(cfg) => cfg,\n    Err(e) => {\n        eprintln!(\"BCS decode failed: {e}; artifact may be from an incompatible version\");\n        // fall back to regenerating the artifact\n        regenerate_config()? \n    }\n}","preventionTips":["Keep client and node versions in sync for shared binary artifacts","Never hand-edit BCS-encoded files; use the CLI or JSON config","Wrap BCS blobs with a version/ magic prefix when you control the format","Store configs as JSON (human-editable) and let the library handle BCS internally"],"tags":["serialization","bcs","rust","deserialization"],"backgroundTag":"bcs-deserialization-failed","analyzedSha":"fc4714a8ea273b6efe8b13dbce72ea60aad9a16c","analyzedAt":"2026-09-04T21:07:05.890Z","contentChangedAt":"2026-09-04T21:07:05.890Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}