-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: handle PathError gracefully in add_files_from_stdout #10407
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
Conversation
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
crates/turborepo-scm/src/git.rs
Outdated
| turbo_root: &AbsoluteSystemPath, | ||
| stdout: Vec<u8>, | ||
| ) { | ||
| let stdout = String::from_utf8(stdout).unwrap(); |
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.
This can still panic if there's a non-UTF8 path in the output.
| Ok(anchored_to_turbo_root_file_path) => { | ||
| files.insert(anchored_to_turbo_root_file_path); | ||
| } | ||
| Err(err) => { |
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.
Bubble up this error so it reaches the caller and they can decide what to do with it. In our case when this error is eventually returned in change_detector.rs we should catch it and behave as if every package changed since we cannot identify which exact packages changed. The warning you added should be moved there with an updated message.
…hange_detector Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
…hange_detector Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
…ct success Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
| }) | ||
| .collect()); | ||
| } | ||
| Err(ScmError::Path(err, _)) => { |
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.
Can you deduplicate the generation of "all packages changed due to error" logic?
| .map(|(name, _)| { | ||
| ( | ||
| name.to_owned(), | ||
| PackageInclusionReason::All(AllPackageChangeReason::GitRefNotFound { |
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.
Can you change this variant now that it is for many different git related failures instead of just the ref not being found?
crates/turborepo-scm/src/git.rs
Outdated
| ) { | ||
| let stdout = String::from_utf8(stdout).unwrap(); | ||
| ) -> Result<(), Error> { | ||
| let stdout = String::from_utf8_lossy(&stdout); |
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.
I do not want a lossy conversion as this will cause silent failures upstream. Please report up any non-UTF8 output as an error.
crates/turborepo-scm/src/git.rs
Outdated
| .reanchor_path_from_git_root_to_turbo_root(turbo_root, path) | ||
| .unwrap(); | ||
| files.insert(anchored_to_turbo_root_file_path); | ||
| match RelativeUnixPath::new(line) { |
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.
We do not need to handle the error case for RelativeUnixPath::new failing. We can just unwrap() it as it will only fail if given a path that starts with / and git will not output absolute paths for the command we're parsing.
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
Co-Authored-By: anthony.shew@vercel.com <anthonyshew@gmail.com>
|
Closing this one. Sorry, Devin, I think I prompted you poorly. Maybe some other time. |
|
Hey @anthonyshew I have tried an approach to solve this .Let me know what you think of the new PR in regards to how it handles it.. new PR |
Description
This PR fixes an issue where
crates/turborepo-scm/src/git.rspanics in GitHub Actions when using the--affectedflag with paths containing special characters (particularly Cyrillic symbols).The panic occurs in the
add_files_from_stdoutmethod where it unwraps the result ofreanchor_path_from_git_root_to_turbo_root, which can fail with aPathError::NotParenterror.This PR modifies the code to handle these errors gracefully by skipping problematic paths and logging a warning instead of panicking.
Fixes #10403
Verification
Link to Devin run: https://app.devin.ai/sessions/8bc1623f365c4c5fab3d83c6c1c7279f
Requested by: anthony.shew@vercel.com