fix(security): surface Windows ACL repair hint when .secret_key is unreadable (#1748)

This commit is contained in:
Lunar-feedmob
2026-05-14 22:06:55 -07:00
committed by GitHub
parent 609b6b702b
commit c8b8aeb871
+16 -2
View File
@@ -188,8 +188,22 @@ impl SecretStore {
}
if self.key_path.exists() {
let hex_key = read_key_file_with_retry(&self.key_path)
.context("Failed to read secret key file")?;
let hex_key = read_key_file_with_retry(&self.key_path).with_context(|| {
let mut msg = format!(
"Failed to read secret key file at {}",
self.key_path.display()
);
#[cfg(windows)]
{
msg.push_str(
"\n\nThis is often caused by incorrect file permissions on Windows. \
Try repairing ACLs on the .openhuman directory:\n\
icacls \"%USERPROFILE%\\.openhuman\" /reset /t /c\n\
icacls \"%USERPROFILE%\\.openhuman\\.secret_key\" /reset /c",
);
}
msg
})?;
let key = hex_decode(hex_key.trim()).context("Secret key file is corrupt")?;
anyhow::ensure!(
key.len() == KEY_LEN,