Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-token-dir-error-propagation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gws": patch
---

Fix auth error propagation: properly propagate errors when token directory creation or permission setting fails, instead of silently ignoring them
17 changes: 15 additions & 2 deletions src/token_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,24 @@ impl EncryptedTokenStorage {
let encrypted = crate::credential_store::encrypt(json.as_bytes())?;

if let Some(parent) = self.file_path.parent() {
let _ = tokio::fs::create_dir_all(parent).await;
tokio::fs::create_dir_all(parent).await.map_err(|e| {
anyhow::anyhow!(
"Failed to create token directory '{}': {}",
sanitize_for_terminal(&parent.display().to_string()),
e
)
})?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let _ = std::fs::set_permissions(parent, std::fs::Permissions::from_mode(0o700));
std::fs::set_permissions(parent, std::fs::Permissions::from_mode(0o700))
.map_err(|e| {
anyhow::anyhow!(
"Failed to set permissions on token directory '{}': {}",
sanitize_for_terminal(&parent.display().to_string()),
e
)
})?;
}
}

Expand Down
Loading