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

Get error when try to delete blob snapshot #84

Closed
jcookems opened this issue May 21, 2012 · 2 comments
Closed

Get error when try to delete blob snapshot #84

jcookems opened this issue May 21, 2012 · 2 comments

Comments

@jcookems
Copy link
Contributor

The message sent by using this code:

    service.createPageBlob(container, blob, 512);
    CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob);
    options = new DeleteBlobOptions();
    options.setSnapshot(snapshot.getSnapshot());
    service.deleteBlob(container, blob, options);

is

DELETE http://XXX.blob.core.windows.net/XXX/XXX?snapshot=2012-05-21T16:15:40.1301586Z HTTP/1.1
x-ms-version: 2011-08-18
x-ms-delete-snapshots: include
...

which returns

HTTP/1.1 400 Value for one of the query parameters specified in the request URI is invalid.
QueryParameterName: snapshot
QueryParameterValue: 2012-05-21T16:15:40.1301586Z
Reason: This operation is only allowed on the root blob. Snapshot should not be provided.

The reason for this is explained (somewhat) in the documentation at http://msdn.microsoft.com/en-us/library/windowsazure/dd179413:

x-ms-delete-snapshots: {include, only}
...
This header should be specified only for a request against the base blob resource. If this header is specified on a request to delete an individual snapshot, the Blob service returns status code 400 (Bad Request).

There are a few potential fixes.

  1. Change the options class to make the DeleteSnaphotsOnly property nullable, and not include the header if null. But that makes the user have to do more work, because that makes them unable to delete a blob which has associated snapshots unless they explicitly set DeleteSnapshotsOnly to false. But that might be more appropriate for a service layer.
  2. Another choice would be to only add the x-ms-delete-snapshots header if there is no snapshot id provided, and silently ignore the user-supplied DeleteSnaphotsOnly property.
  3. Same as (2), but throw an exception to indicate the error (like invalid argument exception) to indicate that it is an error to specify both DeleteSnaphotsOnly and a snapshot.

I'm leaning toward (1), because that is most in line with what a service layer should do. A higher-level convenience layer can add in trickier logic for inferring the correct headers.

@gcheng
Copy link

gcheng commented Jul 10, 2012

I think we should have a unit test for this scenario, deleting blob snapshot is a basic scenario to support.

@joostdenijs
Copy link
Contributor

Option 1 is most in-line with the goal of the service layer. When making the fix we should make sure that the javadcos are explicit on the function of each possible value (True, False, null).

@ghost ghost assigned gcheng Jul 13, 2012
@gcheng gcheng closed this as completed Jul 27, 2012
joostdenijs pushed a commit to joostdenijs/azure-sdk-for-java that referenced this issue Jan 18, 2013
subscription Messagecount should be a readonly property. fixes Azure#61
jianghaolu pushed a commit to jianghaolu/azure-sdk-for-java that referenced this issue Apr 5, 2017
subscription Messagecount should be a readonly property. fixes Azure#61
g2vinay pushed a commit to g2vinay/azure-sdk-for-java that referenced this issue Mar 4, 2019
g2vinay pushed a commit to g2vinay/azure-sdk-for-java that referenced this issue Mar 4, 2019
g2vinay pushed a commit to g2vinay/azure-sdk-for-java that referenced this issue Mar 4, 2019
navalev pushed a commit to navalev/azure-sdk-for-java that referenced this issue Dec 24, 2019
* Adds HTTP 207 handling, raising an error when an indexing call was only partially successful
* Adds IndexBatchException
* Updates client to handle HTTP 207
* Updates tests to handle newly thrown errors
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants