Fix NetTrace output path resolution and fail-fast validation for record-trace#272
Conversation
| return Err(anyhow!("{} is a directory.", output_path.display())); | ||
| } | ||
| warn!("NetTrace export path is a directory: path={}", output_path.display()); | ||
| return Err(anyhow!("{} is a directory.", output_path.display())); |
There was a problem hiding this comment.
This error should tell the user what to do - add a file name to the path (e.g. trace.nettrace).
There was a problem hiding this comment.
Updated in commit 9cf3198. The directory-path validation error now includes clear guidance to provide a file path (for example, trace.nettrace).
| if let Some(parent) = output_path.parent().filter(|parent| !parent.as_os_str().is_empty()) { | ||
| if !parent.exists() { | ||
| warn!("NetTrace export parent path does not exist: path={}", parent.display()); | ||
| return Err(anyhow!("{} does not exist.", parent.display())); |
There was a problem hiding this comment.
The error should be clearer - The output directory {} does not exist. Please create it and try again.
There was a problem hiding this comment.
Updated in commit 9cf3198. The missing-directory error now says: "The output directory {} does not exist. Please create it and try again."
| self.output_path.push("trace.nettrace"); | ||
| else if !parent.is_dir() { | ||
| warn!("NetTrace export parent path is not a directory: path={}", parent.display()); | ||
| return Err(anyhow!("{} is not a directory.", parent.display())); |
There was a problem hiding this comment.
Same here - need to tell the user what to do to fix it.
There was a problem hiding this comment.
Updated in commit 9cf3198. The parent-path-type error now includes actionable guidance: "The parent path {} exists but is not a directory. Please provide a path with a valid directory as the parent."
Addressed in commit |
Bug Fix
record-trace --on-cpucould pass a directory path directly to NetTrace export when--outwas omitted (or pointed to a directory), causingIs a directory (os error 21)at export time. The fix ensures NetTrace always resolves a writable file path up front and fails before collection if output is invalid.What was the bug?
How did you fix it?
trace.nettracetrace.nettraceExample