linera-io/linera-protocol · error
Failed to find parse port {port_str} for {s}
Error message
Failed to find parse port {port_str} for {s} What it means
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.
Source
Thrown at linera-storage-runtime/src/storage_config.rs:252
let path_with_guard = PathWithGuard::new(path);
let spawn_mode_name = parts
.get(1)
.copied()
.expect("validated by the parts length check above");
let spawn_mode = match spawn_mode_name {
"spawn_blocking" => Ok(RocksDbSpawnMode::SpawnBlocking),
"block_in_place" => Ok(RocksDbSpawnMode::BlockInPlace),
"runtime" => Ok(RocksDbSpawnMode::get_spawn_mode_from_runtime()),
_ => Err(anyhow!("Failed to parse {spawn_mode_name} as a spawn_mode",)),
}?;
let protocol = parts[2];
if protocol != "tcp" {
bail!("The only allowed protocol is tcp");
}
let address = parts[3];
let port_str = parts[4];
let port = NonZeroU16::from_str(port_str)
.map_err(|_| anyhow!("Failed to find parse port {port_str} for {s}"))?;
let uri = format!("{address}:{port}");
let inner_storage_config = InnerStorageConfig::DualRocksDbScyllaDb {
path_with_guard,
spawn_mode,
uri,
};
let namespace = if parts.len() == 5 {
DEFAULT_NAMESPACE.to_string()
} else {
parts[5].to_string()
};
return Ok(StorageConfig {
inner_storage_config,
namespace,
});
}
error!("available storage: memory");
#[cfg(feature = "storage-service")]View on GitHub (pinned to 6c226ddcb3)
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
Example fix
# before --storage dualrocksdbscylladb:/tmp/db:block_in_place:tcp:host:0 # after --storage dualrocksdbscylladb:/tmp/db:block_in_place:tcp:host:9042
Defensive patterns
Strategy: validation
Validate before calling
// Rust: check the fixed-position port before parsing the dual config
fn dual_port_ok(s: &str) -> bool {
let parts: Vec<_> = s.split(':').collect();
(parts.len() == 5 || parts.len() == 6)
&& parts[2] == "tcp"
&& std::num::NonZeroU16::from_str(parts[4]).is_ok()
} Type guard
fn is_nonzero_u16(s: &str) -> bool { std::num::NonZeroU16::from_str(s).is_ok() } Try / catch
let port = NonZeroU16::from_str(port_str)
.map_err(|_| anyhow::anyhow!("port {port_str} in {s} must be an integer 1..=65535"))?; Prevention
- 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
When it happens
Trigger: --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.
Common situations: Port 0 placeholders; interpolated env vars with stray whitespace; hostname fields containing extra colons that misalign the fixed-position fields.
Related errors
- Failed to find parse port {port_str} for {s}. {parse_error}
- Failed to find address for {s}. {parse_error}
- Failed to find port for {s}. {parse_error}
- 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/0f970d28de3a2685.
Report an issue: GitHub.