-
Notifications
You must be signed in to change notification settings - Fork 0
Propagate silently-swallowed errors in credential/profile writes #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -825,13 +825,18 @@ pub fn isolate_add_with(agent: &str, profile: &str, shallow: bool, json: bool) { | |
| // Copy auth files from vault profile | ||
| activate_into(agent, profile, &dir); | ||
|
|
||
| // Store metadata | ||
| // Store metadata. Without it, read_isolate_mode() later can't tell whether | ||
| // this isolate is shallow or deep, so a failed write must not pass silently. | ||
| let meta = serde_json::json!({"mode": if shallow { "shallow" } else { "deep" }, "agent": agent, "profile": profile}); | ||
| fs::write( | ||
| if let Err(e) = fs::write( | ||
| dir.join("isolate.json"), | ||
| serde_json::to_string_pretty(&meta).unwrap() + "\n", | ||
| ) | ||
| .ok(); | ||
| ) { | ||
| eprintln!( | ||
| "warning: failed to write isolate metadata to {}: {e}", | ||
| dir.display() | ||
| ); | ||
| } | ||
|
|
||
| if json { | ||
| println!( | ||
|
|
@@ -1072,12 +1077,27 @@ fn activate_into(agent: &str, profile: &str, target_dir: &std::path::Path) { | |
|
|
||
| #[cfg(not(windows))] | ||
| fn symlink_or_copy(src: &std::path::Path, dest: &std::path::Path) { | ||
| std::os::unix::fs::symlink(src, dest).ok(); | ||
| warn_on_link_failure(src, dest, std::os::unix::fs::symlink(src, dest)); | ||
| } | ||
|
|
||
| #[cfg(windows)] | ||
| fn symlink_or_copy(src: &std::path::Path, dest: &std::path::Path) { | ||
| fs::copy(src, dest).ok(); | ||
| warn_on_link_failure(src, dest, fs::copy(src, dest).map(|_| ())); | ||
|
Comment on lines
1083
to
+1085
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
curl -fsSL https://doc.rust-lang.org/std/fs/fn.copy.html |
python -c 'import sys; text=sys.stdin.read(); assert "neither a regular file nor a symlink to a regular file" in text'Repository: getappz/agentflare Length of output: 156 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Show the relevant function and surrounding lines.
sed -n '1040,1125p' src/auth.rs
printf '\n---- CALLERS ----\n'
# Find call sites for symlink_or_copy.
grep -RIn --exclude-dir=.git "symlink_or_copy" src || trueRepository: getappz/agentflare Length of output: 3518 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Search the repository for `symlink_or_copy`.
grep -RIn --exclude-dir=.git "symlink_or_copy" .
printf '\n---- src/auth.rs around the symbol ----\n'
grep -n "symlink_or_copy" -n src/auth.rs || trueRepository: getappz/agentflare Length of output: 797 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '760,835p' src/auth.rsRepository: getappz/agentflare Length of output: 2523 Handle directory sources on Windows before calling
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /// An already-present destination is fine (the isolate was set up before); any | ||
| /// other failure means the isolate is missing host state (ssh keys, git config) | ||
| /// it needs, so surface it instead of silently continuing. | ||
| fn warn_on_link_failure(src: &std::path::Path, dest: &std::path::Path, res: std::io::Result<()>) { | ||
| if let Err(e) = res | ||
| && e.kind() != std::io::ErrorKind::AlreadyExists | ||
| { | ||
| eprintln!( | ||
| "warning: failed to link {} into isolate at {}: {e}", | ||
| src.display(), | ||
| dest.display() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Only clean up a temp file after this invocation successfully creates it.
Because
open(&tmp)?is inside the closure,AlreadyExistsalso reaches Line 119 and may delete another concurrent writer’s temp file. Move creation outside the closure, then surface any cleanup failure alongside the original error rather than discarding it.🤖 Prompt for AI Agents