tinyhumansai/openhuman · error · anyhow::Error
Secret key file has wrong length: expected {KEY_LEN} bytes,
Error message
Secret key file has wrong length: expected {KEY_LEN} bytes, got {} What it means
The master key file decoded from hex but is not exactly KEY_LEN bytes (32). The size assertion in `decode_key_hex` fires after successful hex decode — so the file is well-formed hex but wrong length, pointing at a hand-edited, truncated, or foreign key file rather than decode corruption.
Source
Thrown at src/openhuman/security/keyring/encrypted_store.rs:658
/// XOR cipher with repeating key. Same function for encrypt and decrypt.
fn xor_cipher(data: &[u8], key: &[u8]) -> Vec<u8> {
if key.is_empty() {
return data.to_vec();
}
data.iter()
.enumerate()
.map(|(i, &b)| b ^ key[i % key.len()])
.collect()
}
fn generate_random_key() -> Zeroizing<Vec<u8>> {
Zeroizing::new(crypto::generate_random_bytes(KEY_LEN))
}
fn decode_key_hex(hex_key: &str) -> Result<Zeroizing<Vec<u8>>> {
let key = Zeroizing::new(hex_decode(hex_key).context("Secret key file is corrupt")?);
anyhow::ensure!(
key.len() == KEY_LEN,
"Secret key file has wrong length: expected {KEY_LEN} bytes, got {}",
key.len()
);
Ok(key)
}
fn hex_encode(data: &[u8]) -> String {
crypto::hex_encode(data)
}
/// Build the `/grant` argument for `icacls` using a normalized username.
/// Returns `None` when the username is empty or whitespace-only.
fn build_windows_icacls_grant_arg(username: &str) -> Option<String> {
let normalized = username.trim();
if normalized.is_empty() {
return None;
}View on GitHub (pinned to 7491200858)
Solutions
- Restore the original 32-byte key file from backup
- Regenerate the key (secrets encrypted with the old key become unrecoverable) and re-enter secrets
- Prevent manual edits to the key file; it is binary key material in hex
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/openhuman/security/keyring/encrypted_store.rs:658 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17).
Data as JSON: /api/errors/40dd1d4d5f7fc8bd.
Report an issue: GitHub.