linera-io/linera-protocol · error
Validator spec must be in format: public_key,account_key,add
Error message
Validator spec must be in format: public_key,account_key,address,votes
What it means
A validator specification passed on the command line did not contain exactly four comma-separated fields. ValidatorToAdd::from_str expects `public_key,account_key,address,votes`, where address is itself a protocol:host:port string and votes is a number; a wrong field count fails before any field is parsed.
Source
Thrown at linera-service/src/cli/command.rs:51
/// Specification for a validator to be added to the committee.
#[derive(Clone, Debug)]
pub struct ValidatorToAdd {
/// The validator's public key.
pub public_key: ValidatorPublicKey,
/// The validator's account public key.
pub account_key: AccountPublicKey,
/// The network address of the validator.
pub address: String,
/// The number of votes assigned to the validator.
pub votes: u64,
}
impl std::str::FromStr for ValidatorToAdd {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts: Vec<&str> = s.split(',').collect();
anyhow::ensure!(
parts.len() == 4,
"Validator spec must be in format: public_key,account_key,address,votes"
);
Ok(ValidatorToAdd {
public_key: parts[0].parse()?,
account_key: parts[1].parse()?,
address: parts[2].to_string(),
votes: parts[3].parse()?,
})
}
}
#[derive(Clone, clap::Args, serde::Serialize)]
#[serde(rename_all = "kebab-case")]
/// Options controlling the behavior of the benchmark command.
pub struct BenchmarkOptions {
/// How many chains to use.View on GitHub (pinned to 6c226ddcb3)
Solutions
- Provide all four fields in order: BLS public key, account key, network address, vote count.
- Example shape: --validators "<public_key>,<account_key>,grpc:host:9000,10".
- Remove trailing/leading commas and spaces around the value.
- Confirm both keys are valid hex/base64 for the expected key types before composing the string.
Example fix
# before: missing fields --validators "<public_key>,grpc:host:9000" # after: public_key,account_key,address,votes --validators "<public_key>,<account_key>,grpc:host:9000,10"
Defensive patterns
Strategy: type-guard
Validate before calling
fn is_valid_validator_spec(s: &str) -> bool {
let parts: Vec<_> = s.split(',').collect();
parts.len() == 4
&& parts[0].parse::<PublicKey>().is_ok()
&& parts[1].parse::<AccountPublicKey>().is_ok()
&& parts[2].parse::<ValidatorPublicNetworkConfig>().is_ok()
&& parts[3].parse::<u64>().is_ok()
} Type guard
fn is_valid_validator_spec(s: &str) -> bool {
s.split(',').count() == 4 && !s.split(',').any(str::is_empty)
} Try / catch
match s.parse::<ValidatorToAdd>() {
Ok(v) => v,
Err(e) => {
eprintln!("invalid validator spec (want public_key,account_key,address,votes): {e}");
std::process::exit(2);
}
} Prevention
- Build the spec string from typed values with format!("{pk},{ak},{addr},{votes}").
- Add a config-lint step that parses every validator spec before deployment.
When it happens
Trigger: Passing only the key pair and address (omitting votes, needed for weighted consensus), a trailing comma creating an empty fifth field, or keys containing/unbalanced delimiters.
Common situations: Older docs or scripts that predate the account_key or votes fields; copy-pasting from a table where a column was dropped; forgetting that votes is mandatory even for weight 1.
Related errors
- Expecting format `(tcp|udp|grpc|grpcs):host:port`
- {s}
- The input has not matched: {input}
- TLS not supported between proxy and shards.
- We should have one genesis config path and one optional name
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/c02de75a97281eab.
Report an issue: GitHub.