linera-io/linera-protocol · error
Failed to find port for {s}. {parse_error}
Error message
Failed to find port for {s}. {parse_error} What it means
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'.
Source
Thrown at linera-storage-runtime/src/storage_config.rs:191
});
}
bail!("We should have one, two or three parts");
}
#[cfg(feature = "scylladb")]
if let Some(s) = input.strip_prefix(SCYLLA_DB) {
let mut uri: Option<String> = None;
let mut namespace: Option<String> = None;
let parse_error: &'static str = "Correct format is tcp:db_hostname:port.";
if !s.is_empty() {
let mut parts = s.split(':');
while let Some(part) = parts.next() {
match part {
"tcp" => {
let address = parts.next().ok_or_else(|| {
anyhow!("Failed to find address for {s}. {parse_error}")
})?;
let port_str = parts.next().ok_or_else(|| {
anyhow!("Failed to find port for {s}. {parse_error}")
})?;
let port = NonZeroU16::from_str(port_str).map_err(|_| {
anyhow!(
"Failed to find parse port {port_str} for {s}. {parse_error}",
)
})?;
if uri.is_some() {
bail!("The uri has already been assigned");
}
uri = Some(format!("{address}:{port}"));
}
_ if part.starts_with("table") => {
if namespace.is_some() {
bail!("The namespace has already been assigned");
}
namespace = Some(part.to_string());
}
_ => {View on GitHub (pinned to 6c226ddcb3)
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
Example fix
# before --storage scylladb:tcp:db.example.com # after --storage scylladb:tcp:db.example.com:9042
Defensive patterns
Strategy: validation
Validate before calling
// Rust: ensure every tcp segment has host AND port
fn tcp_segments_complete(s: &str) -> bool {
let mut parts = s.split(':');
while let Some(part) = parts.next() {
if part == "tcp" {
if parts.next().unwrap_or("").is_empty() { return false; }
if parts.next().unwrap_or("").is_empty() { return false; }
}
}
true
} Type guard
fn has_complete_tcp_endpoint(s: &str) -> bool { tcp_segments_complete(s) } Try / catch
if let Err(e) = StorageConfig::from_str(&storage) {
eprintln!("storage config rejected: {e:#}; expected scylladb:tcp:host:port");
std::process::exit(2);
} Prevention
- 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
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- Failed to find address for {s}. {parse_error}
- Failed to find parse port {port_str} for {s}. {parse_error}
- Failed to find parse port {port_str} for {s}
- Failed to parse {spawn_mode_name} as a spawn_mode
- The input has not matched: {input}
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/a88cd10772f3e142.
Report an issue: GitHub.