{"record":{"id":"a88cd10772f3e142","repo":"linera-io/linera-protocol","slug":"failed-to-find-port-for-s-parse-error","errorCode":null,"errorMessage":"Failed to find port for {s}. {parse_error}","messagePattern":"Failed to find port for (.+?)\\. (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-storage-runtime/src/storage_config.rs","lineNumber":191,"sourceCode":"                });\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;\n            let parse_error: &'static str = \"Correct format is tcp:db_hostname:port.\";\n            if !s.is_empty() {\n                let mut parts = s.split(':');\n                while let Some(part) = parts.next() {\n                    match part {\n                        \"tcp\" => {\n                            let address = parts.next().ok_or_else(|| {\n                                anyhow!(\"Failed to find address for {s}. {parse_error}\")\n                            })?;\n                            let port_str = parts.next().ok_or_else(|| {\n                                anyhow!(\"Failed to find port for {s}. {parse_error}\")\n                            })?;\n                            let port = NonZeroU16::from_str(port_str).map_err(|_| {\n                                anyhow!(\n                                    \"Failed to find parse port {port_str} for {s}. {parse_error}\",\n                                )\n                            })?;\n                            if uri.is_some() {\n                                bail!(\"The uri has already been assigned\");\n                            }\n                            uri = Some(format!(\"{address}:{port}\"));\n                        }\n                        _ if part.starts_with(\"table\") => {\n                            if namespace.is_some() {\n                                bail!(\"The namespace has already been assigned\");\n                            }\n                            namespace = Some(part.to_string());\n                        }\n                        _ => {","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-storage-runtime/src/storage_config.rs#L173-L209","documentation":"While parsing the 'tcp' segment of a scylladb storage URL, from_str expects two tokens after 'tcp': the hostname and then the port. This error means the hostname was consumed but the port token is missing — the string ends after 'tcp:hostname'.","triggerScenarios":"Passing --storage 'scylladb:tcp:db.example.com' without a port. Every tcp segment must be 'tcp:hostname:port', e.g. 'scylladb:tcp:db.example.com:9042'.","commonSituations":"Assuming a default port is implied (it is not — omit the whole tcp segment instead to get localhost:9042); URLs edited by hand or truncated in scripts.","solutions":["Add an explicit nonzero port: --storage scylladb:tcp:db.example.com:9042","Or remove the incomplete tcp segment and rely on the localhost:9042 default"],"exampleFix":"# before\n--storage scylladb:tcp:db.example.com\n# after\n--storage scylladb:tcp:db.example.com:9042","handlingStrategy":"validation","validationCode":"// Rust: ensure every tcp segment has host AND port\nfn tcp_segments_complete(s: &str) -> bool {\n    let mut parts = s.split(':');\n    while let Some(part) = parts.next() {\n        if part == \"tcp\" {\n            if parts.next().unwrap_or(\"\").is_empty() { return false; }\n            if parts.next().unwrap_or(\"\").is_empty() { return false; }\n        }\n    }\n    true\n}","typeGuard":"fn has_complete_tcp_endpoint(s: &str) -> bool { tcp_segments_complete(s) }","tryCatchPattern":"if let Err(e) = StorageConfig::from_str(&storage) {\n    eprintln!(\"storage config rejected: {e:#}; expected scylladb:tcp:host:port\");\n    std::process::exit(2);\n}","preventionTips":["Never hand-assemble endpoint strings from optional parts without final validation","In scripts, echo the assembled --storage value before launching so truncation is visible","Remember the tcp segment requires both fields — there is no implicit default port inside it"],"tags":["linera","storage","scylladb","config","parsing","connection-string"],"backgroundTag":"connection-string-parse-error","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}