{"record":{"id":"0f970d28de3a2685","repo":"linera-io/linera-protocol","slug":"failed-to-find-parse-port-port-str-for-s","errorCode":null,"errorMessage":"Failed to find parse port {port_str} for {s}","messagePattern":"Failed to find parse port (.+?) for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-storage-runtime/src/storage_config.rs","lineNumber":252,"sourceCode":"            let path_with_guard = PathWithGuard::new(path);\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 protocol = parts[2];\n            if protocol != \"tcp\" {\n                bail!(\"The only allowed protocol is tcp\");\n            }\n            let address = parts[3];\n            let port_str = parts[4];\n            let port = NonZeroU16::from_str(port_str)\n                .map_err(|_| anyhow!(\"Failed to find parse port {port_str} for {s}\"))?;\n            let uri = format!(\"{address}:{port}\");\n            let inner_storage_config = InnerStorageConfig::DualRocksDbScyllaDb {\n                path_with_guard,\n                spawn_mode,\n                uri,\n            };\n            let namespace = if parts.len() == 5 {\n                DEFAULT_NAMESPACE.to_string()\n            } else {\n                parts[5].to_string()\n            };\n            return Ok(StorageConfig {\n                inner_storage_config,\n                namespace,\n            });\n        }\n        error!(\"available storage: memory\");\n        #[cfg(feature = \"storage-service\")]","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-storage-runtime/src/storage_config.rs#L234-L270","documentation":"In the dual rocksdbscylladb config, parts[4] is the port and is parsed with NonZeroU16::from_str after the 'tcp' protocol and hostname checks pass. This error means the port token is present but is not a valid nonzero u16.","triggerScenarios":"--storage 'dualrocksdbscylladb:/tmp/db:block_in_place:tcp:host:0' or ':host:9o42'. Only integers 1..=65535 are accepted; note the whole config is ':'-split so an IPv6 literal in the hostname field also shifts the fields and breaks the port.","commonSituations":"Port 0 placeholders; interpolated env vars with stray whitespace; hostname fields containing extra colons that misalign the fixed-position fields.","solutions":["Use an integer port in 1..=65535, typically 9042 for ScyllaDB","Count your colons: directory, mode, tcp, hostname, port, (optional) namespace — exactly 5 or 6 fields after the prefix","Use a DNS hostname, not a raw IPv6 address, since ':' is the field separator"],"exampleFix":"# before\n--storage dualrocksdbscylladb:/tmp/db:block_in_place:tcp:host:0\n# after\n--storage dualrocksdbscylladb:/tmp/db:block_in_place:tcp:host:9042","handlingStrategy":"validation","validationCode":"// Rust: check the fixed-position port before parsing the dual config\nfn dual_port_ok(s: &str) -> bool {\n    let parts: Vec<_> = s.split(':').collect();\n    (parts.len() == 5 || parts.len() == 6)\n        && parts[2] == \"tcp\"\n        && std::num::NonZeroU16::from_str(parts[4]).is_ok()\n}","typeGuard":"fn is_nonzero_u16(s: &str) -> bool { std::num::NonZeroU16::from_str(s).is_ok() }","tryCatchPattern":"let port = NonZeroU16::from_str(port_str)\n    .map_err(|_| anyhow::anyhow!(\"port {port_str} in {s} must be an integer 1..=65535\"))?;","preventionTips":["Avoid raw IPv6 literals in these ':'-delimited strings; use hostnames","Validate the assembled string field-by-field before handing it to from_str","Keep the port out of unquoted variable interpolation to avoid stray characters"],"tags":["linera","storage","scylladb","config","parsing","port"],"backgroundTag":"invalid-port-number","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}