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

[BUG] DataLakeFileClient Upload / UploadAsync fail on readonly files #14608

Closed
ohadschn opened this issue Aug 27, 2020 · 6 comments · Fixed by #14864
Closed

[BUG] DataLakeFileClient Upload / UploadAsync fail on readonly files #14608

ohadschn opened this issue Aug 27, 2020 · 6 comments · Fixed by #14864
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Data Lake Storage Gen2 needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)

Comments

@ohadschn
Copy link

ohadschn commented Aug 27, 2020

Describe the bug
There are 3 places in DataLakeFileClient where a FileStream is created with unnecessary write access (implicit by the latter's ctor):

using (FileStream stream = new FileStream(path, FileMode.Open))

using (FileStream stream = new FileStream(path, FileMode.Open))

using (FileStream stream = new FileStream(path, FileMode.Open))

This will cause failures when trying to upload readonly files.

Windows sample stack trace:

System.UnauthorizedAccessException: Access to the path 'C:\foo.rnd' is denied.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Azure.Storage.Files.DataLake.DataLakeFileClient.UploadAsync(String path, PathHttpHeaders httpHeaders, DataLakeRequestConditions conditions, IProgress`1 progressHandler, StorageTransferOptions transferOptions, CancellationToken cancellationToken)

OSX sample stack trace:

System.UnauthorizedAccessException: Access to the path '/Users/johndoe/foo.bar' is denied.
 ---> System.IO.IOException: Operation not permitted
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Azure.Storage.Files.DataLake.DataLakeFileClient.UploadAsync(String path, PathHttpHeaders httpHeaders, DataLakeRequestConditions conditions, IProgress`1 progressHandler, StorageTransferOptions transferOptions, CancellationToken cancellationToken)
   at Microsoft.Azure.DashCamUploader.DataLakeUploader.Upload(String file) in 

To Reproduce
Call one of the DataLakeFileClient::UploadAsync/DataLakeFileClient::Upload overrides which accepts a file name (string)

Workaround
Use one of the DataLakeFileClient::UploadAsync/DataLakeFileClient::Upload overrides accepting a Stream, and pass it File.OpenRead(path)

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Aug 27, 2020
@ohadschn ohadschn changed the title [BUG] [BUG] DataLakeFileClient Upload / UploadAsync fail on readonly files Aug 27, 2020
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. Data Lake Storage Gen2 needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. labels Aug 27, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 27, 2020
@jsquire
Copy link
Member

jsquire commented Aug 27, 2020

Thank you for your feedback. Tagging and routing to the team best able to assist.

@ghost
Copy link

ghost commented Aug 27, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sumantmehtams.

@sumantmehtams
Copy link

Adding @seanmcc-msft to take a look.

@seanmcc-msft
Copy link
Member

Hi @ohadschn, thanks for the detailed bug report. I'll work to get this fixed in our next release.

-Sean

@seanmcc-msft seanmcc-msft self-assigned this Sep 2, 2020
@seanmcc-msft seanmcc-msft added Storage Storage Service (Queues, Blobs, Files) and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 2, 2020
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 2, 2020
@ghost
Copy link

ghost commented Sep 2, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

@ohadschn
Copy link
Author

ohadschn commented Sep 4, 2020

@seanmcc-msft thank you but I think you missed one?

using (FileStream stream = new FileStream(path, FileMode.Open))

@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Data Lake Storage Gen2 needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
4 participants