{"record":{"id":"39c15ceb0868ea45","repo":"linera-io/linera-protocol","slug":"failed-to-parse-spawn-mode-name-as-a-spawn-mode","errorCode":null,"errorMessage":"Failed to parse {spawn_mode_name} as a spawn_mode","messagePattern":"Failed to parse (.+?) as a spawn_mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-storage-runtime/src/storage_config.rs","lineNumber":162,"sourceCode":"                let namespace = DEFAULT_NAMESPACE.to_string();\n                let spawn_mode = RocksDbSpawnMode::SpawnBlocking;\n                let inner_storage_config = InnerStorageConfig::RocksDb { path, spawn_mode };\n                return Ok(StorageConfig {\n                    inner_storage_config,\n                    namespace,\n                });\n            }\n            if parts.len() == 2 || parts.len() == 3 {\n                let path = parts[0].to_string().into();\n                let spawn_mode_name = parts\n                    .get(1)\n                    .copied()\n                    .expect(\"validated by the parts length check above\");\n                let spawn_mode = match spawn_mode_name {\n                    \"spawn_blocking\" => Ok(RocksDbSpawnMode::SpawnBlocking),\n                    \"block_in_place\" => Ok(RocksDbSpawnMode::BlockInPlace),\n                    \"runtime\" => Ok(RocksDbSpawnMode::get_spawn_mode_from_runtime()),\n                    _ => Err(anyhow!(\"Failed to parse {spawn_mode_name} as a spawn_mode\")),\n                }?;\n                let namespace = if parts.len() == 2 {\n                    DEFAULT_NAMESPACE.to_string()\n                } else {\n                    parts[2].to_string()\n                };\n                let inner_storage_config = InnerStorageConfig::RocksDb { path, spawn_mode };\n                return Ok(StorageConfig {\n                    inner_storage_config,\n                    namespace,\n                });\n            }\n            bail!(\"We should have one, two or three parts\");\n        }\n        #[cfg(feature = \"scylladb\")]\n        if let Some(s) = input.strip_prefix(SCYLLA_DB) {\n            let mut uri: Option<String> = None;\n            let mut namespace: Option<String> = None;","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-storage-runtime/src/storage_config.rs#L144-L180","documentation":"When parsing a rocksdb storage config string of the form rocksdb:directory:spawn_mode[:namespace], StorageConfig::from_str matches the spawn_mode token against the allowed values. Only 'spawn_blocking', 'block_in_place' and 'runtime' are accepted; anything else produces this error naming the offending token.","triggerScenarios":"Configuring storage like 'rocksdb:/tmp/linera:spawn_blocking' is fine, but 'rocksdb:/tmp/linera:blocking', 'rocksdb:/tmp/linera:thread' or a misplaced field (e.g. passing the namespace in the spawn_mode slot) fails here. Raised from from_str(), typically while parsing the --storage CLI argument at startup.","commonSituations":"Guessing the enum value instead of checking the three literals; older tutorials naming modes differently; field-order confusion between directory, spawn mode and optional namespace.","solutions":["Use one of the three literal values: spawn_blocking, block_in_place, or runtime","Re-check field order: rocksdb:<directory>:<spawn_mode> or rocksdb:<directory>:<spawn_mode>:<namespace>","If you do not care about the mode, use the short form 'rocksdb:<directory>' which defaults to spawn_blocking"],"exampleFix":"# before\n--storage rocksdb:/tmp/linera:blocking\n# after\n--storage rocksdb:/tmp/linera:block_in_place","handlingStrategy":"validation","validationCode":"// Rust: validate spawn_mode before building the config string\nfn is_valid_spawn_mode(s: &str) -> bool {\n    matches!(s, \"spawn_blocking\" | \"block_in_place\" | \"runtime\")\n}\nif let Some(mode) = spawn_mode {\n    anyhow::ensure!(is_valid_spawn_mode(mode), \"spawn_mode must be spawn_blocking|block_in_place|runtime\");\n}","typeGuard":"fn is_valid_spawn_mode(s: &str) -> bool {\n    matches!(s, \"spawn_blocking\" | \"block_in_place\" | \"runtime\")\n}","tryCatchPattern":"match StorageConfig::from_str(&storage_str) {\n    Ok(cfg) => cfg,\n    Err(e) => {\n        eprintln!(\"bad --storage {storage_str:?}: {e:#}\");\n        std::process::exit(2);\n    }\n}","preventionTips":["Offer a CLI enum (clap ValueEnum) for spawn mode instead of a free-text string","Document the three literals at every place the storage string is configured","Unit-test config parsing with all valid modes plus one invalid string to keep the contract visible"],"tags":["linera","storage","rocksdb","config","parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}