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

400 Error when using FileClient.Delete() with ApiVersion[2023-08-03] and OAuth in Storage Datalake SDK #37869

Closed
microzchang opened this issue Jul 27, 2023 · 8 comments
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 question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@microzchang
Copy link
Member

Library name and version

Azure.Storage.Files.Datalake.12.16.0.alpha.20230726.1

Describe the bug

In the latest source code of Storage Datalake SDK, when using FileClient.Delete() with ApiVersion2023-08-03 and OAuth, the query parameter of the request should be paginated=true&recursive=false. This combination produces a 400 error no matter if the resourceType is file or directory.

Expected behavior

Return success instead of 400 error.

Actual behavior

Return HttpStatusCode 400 with message: A query parameter that's mandatory for this request is not specified.

Reproduction Steps

  1. Use the latest source code with include feature Paginated Directory Delete to build.
  2. Use FileClient.Delete() with ApiVersion2023-08-03 and OAuth

There is also a x-ms-reuqest-id about this issue to search server log: c2e472e5-101f-0047-3430-c026fb000000

Environment

Visual Studio 2022

@microzchang microzchang added Storage Storage Service (Queues, Blobs, Files) Data Lake Storage Gen2 labels Jul 27, 2023
@jsquire jsquire added 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. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team CXP Attention and removed Storage Storage Service (Queues, Blobs, Files) labels Jul 27, 2023
@github-actions
Copy link

Thank you for your feedback. This has been routed to the support team for assistance.

@seanmcc-msft
Copy link
Member

seanmcc-msft commented Jul 27, 2023

The paginated and recursive query parameters do not apply to file delete - https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete

@microzchang
Copy link
Member Author

microzchang commented Jul 28, 2023

Hi, Sean.
Thanks for your reply,I think The paginated and recursive query parameters do not apply to file delete is right.
But in the impl of .Net SDK, DatalakeFileClient.Delete() will use DtalakePathClient.Delete(), which will set paginated=true when ApiVersion = 2023-08-03 and TokenCredential is not null. This will trigger a 400 error.

You can easily reproduce this 400 error by using following code:

DataLakeClientOptions options = new DataLakeClientOptions(DataLakeClientOptions.ServiceVersion.V2023_08_03);

//AAD with RBAC permission
ClientSecretCredential credential = new ClientSecretCredential("AAD_TENANT_ID", "AAD_CLIENT_ID", "AAD_SCERET");


var oauthService = new DataLakeServiceClient(new Uri("https://zchangdatalakecanary.dfs.core.windows.net"), credential, options);
var oauthFileSystem = oauthService.GetFileSystemClient("test1");
oauthFileSystem.CreateIfNotExists();
var oauthFile = oauthFileSystem.GetFileClient("file1");
oauthFile.CreateIfNotExists();
oauthFile.Delete();

oauthFileSystem.Delete();

And you can get the following error:

 Message: 
Azure.RequestFailedException : A query parameter that's mandatory for this request is not specified.
RequestId:da28406e-001f-0039-7bf9-c0b6bc000000
Time:2023-07-28T02:14:35.8452650Z
Status: 400 (A query parameter that's mandatory for this request is not specified.)
ErrorCode: MissingRequiredQueryParameter

Content:
{"error":{"code":"MissingRequiredQueryParameter","message":"A query parameter that's mandatory for this request is not specified.\nRequestId:da28406e-001f-0039-7bf9-c0b6bc000000\nTime:2023-07-28T02:14:35.8452650Z"}}

Headers:
Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code: MissingRequiredQueryParameter
x-ms-request-id: da28406e-001f-0039-7bf9-c0b6bc000000
x-ms-version: 2023-08-03
x-ms-client-request-id: 03e333ce-5310-4fed-84a2-d2859361ee2d
Date: Fri, 28 Jul 2023 02:14:34 GMT
Content-Length: 215
Content-Type: application/json;charset=utf-8


  Stack Trace: 
PathRestClient.Delete(Nullable`1 timeout, Nullable`1 recursive, String continuation, String leaseId, String ifMatch, String ifNoneMatch, Nullable`1 ifModifiedSince, Nullable`1 ifUnmodifiedSince, Nullable`1 paginated, CancellationToken cancellationToken) line 946
DataLakePathClient.DeleteInternal(Nullable`1 recursive, DataLakeRequestConditions conditions, Boolean async, CancellationToken cancellationToken) line 1891
TaskExtensions.EnsureCompleted[T](Task`1 task) line 33
DataLakePathClient.Delete(Nullable`1 recursive, DataLakeRequestConditions conditions, CancellationToken cancellationToken) line 1763
DataLakeFileClient.Delete(DataLakeRequestConditions conditions, CancellationToken cancellationToken) line 931
Sample01a_HelloWorld.CreateFileClient_Filesystem() line 48

@microzchang microzchang reopened this Jul 28, 2023
@microzchang
Copy link
Member Author

microzchang commented Jul 28, 2023

And another thing is that the TokenCredential may not pass correctly to _clientConfiguration when directly using following API to create FileClient/DirectoryClient:

ClientSecretCredential credential = new ClientSecretCredential("AAD_TENANT_ID", "AAD_CLIENT_ID", "AAD_SCERET");

var oauthFile = new DataLakeFileClient(new Uri("DFS_FILE_URI"), credential, options);
var oauthDirectory = new DataLakeDirectoryClient(new Uri("DFS_DIRECTORY_URI"), credential, options);

The TokenCredential field in _clientConfiguration of FileClient/DirectoryClient will be empty.

The code line:
FileClient
DirectoryClient

This can cause the value of paginated to be set incorrectly when Delete().

@navba-MSFT navba-MSFT added Service Attention Workflow: This issue is responsible by Azure service team. and removed CXP Attention labels Jul 28, 2023
@navba-MSFT
Copy link
Contributor

Adding Service team to look into this

@github-actions
Copy link

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

@seanmcc-msft
Copy link
Member

This was fixed with #37934

@seanmcc-msft
Copy link
Member

The 2nd issue was fixed with #38083

@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 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 question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants