databendlabs/databend · error · InvalidInput
semaphore permit key should have at least 3 segments
Error message
semaphore permit key should have at least 3 segments: {} What it means
A generic input-validation guard in PermitKey::parse_key: after splitting the encoded key string with rsplitn(3, '/'), it must yield exactly three segments (seq, "queue", prefix). This error fires when the key string is malformed — missing slashes or fewer than three parts — typically because the stored key was corrupted or produced by an incompatible format.
Solutions
- Ensure the key string passed to parse_key was produced by format_key and contains at least three '/'-separated segments.
- If the key comes from persistent storage, check for corruption or truncation and re-derive or regenerate the permit key.
- Before calling parse_key, validate that key.matches('/').count() >= 2 and handle invalid input explicitly.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/meta/plugins/semaphore/src/storage/permit_key.rs:62 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/14e10467a2e35f83.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/plugins/semaphore/src/storage/permit_key.rs:62
pub fn new(prefix: impl ToString, seq: PermitSeq) -> Self {
Self {
prefix: prefix.to_string(),
seq,
}
}
/// Format the key to a string, keep order preserving.
pub fn format_key(&self) -> String {
format!("{}/queue/{:020}", self.prefix, self.seq)
}
/// Parse the key from an encoded string.
pub fn parse_key(key: &str) -> Result<Self, io::Error> {
// split by the last 2 slashes:
let parts = key.rsplitn(3, '/').collect::<Vec<_>>();
if parts.len() != 3 {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!(
"semaphore permit key should have at least 3 segments: {}",
key
),
));
}
if parts[1] != "queue" {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!(
"semaphore permit key should have 'queue' as the second segment: {}",
key
),
));
}
View on GitHub (pinned to 288d84d76e)