Skip to content
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

gateway: restore original filename in StatFile error message #4321

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

jedevc
Copy link
Member

@jedevc jedevc commented Oct 11, 2023

Follow-up to #3990, but this time for StatFile as well.

This case is a little bit trickier, since it is wrapped by errors.WithStack as well, but we can use errors.Cause to extract the original error to modify it.

Messages returned by fsutil.Stat are guaranteed to return a PathError wrapped by a stack trace (since it calls os.Lstat). However, as these error messages are printed, they include the temporary directory for the mounted reference which is not useful to the caller.

On an error, we can restore the filename in the PathError to the requested filename, as also seen in os.DirFS.

Follow-up to 38040ae.

Messages returned by fsutil.Stat are guaranteed to return a PathError
wrapped by a stack trace (since it calls os.Lstat). However, as these
error messages are printed, they include the temporary directory for the
mounted reference which is not useful to the caller.

On an error, we can restore the filename in the PathError to the
requested filename, as also seen in os.DirFS.

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc jedevc merged commit 86e25b3 into moby:master Oct 11, 2023
52 of 56 checks passed
@jedevc jedevc deleted the fix-stat-file-path-error branch October 11, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants