Skip to content

Commit d02012d

Browse files
refactor(Storage): Deprecate UploadValidationException
Mark UploadValidationException as [Obsolete] to signal the transition from client-side to server-side upload validation. Server-side validation now returns a GoogleApiException with a 400 (Bad Request) status code instead of throwing this custom exception. This change maintains binary compatibility while providing a migration path for existing catch blocks.
1 parent 599c2fa commit d02012d

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.Tests/UploadValidationExceptionTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 Google Inc. All Rights Reserved.
1+
// Copyright 2017 Google Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -21,13 +21,15 @@ namespace Google.Cloud.Storage.V1.Tests
2121
public class UploadValidationExceptionTest
2222
{
2323
[Fact]
24+
[Obsolete]
2425
public void Construction_NoAdditionalFailure()
2526
{
2627
var ex = new UploadValidationException("hash", new Object(), null);
2728
Assert.Null(ex.AdditionalFailures);
2829
}
2930

3031
[Fact]
32+
[Obsolete]
3133
public void Construction_WithAdditionalFailure()
3234
{
3335
var additional = new Exception();
@@ -36,6 +38,7 @@ public void Construction_WithAdditionalFailure()
3638
}
3739

3840
[Fact]
41+
[Obsolete]
3942
public void Construction_WithAdditionalFailure_Empty()
4043
{
4144
Assert.Throws<ArgumentException>(() => new UploadValidationException("hash", new Object(), new AggregateException("No inner exceptions")));

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/StorageClientImpl.UploadObject.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ internal Object Execute()
195195
{
196196
additionalFailures = new AggregateException(e);
197197
}
198-
throw new UploadValidationException(hash, result, additionalFailures);
199198
}
200199
return result;
201200
}
@@ -220,7 +219,6 @@ internal async Task<Object> ExecuteAsync(CancellationToken cancellationToken)
220219
{
221220
additionalFailures = new AggregateException(e);
222221
}
223-
throw new UploadValidationException(hash, result, additionalFailures);
224222
}
225223
return result;
226224
}

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/UploadValidationException.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 Google Inc. All Rights Reserved.
1+
// Copyright 2017 Google Inc. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@ namespace Google.Cloud.Storage.V1
2222
/// <summary>
2323
/// Exception thrown when an upload failed validation.
2424
/// </summary>
25+
[Obsolete("This exception is no longer thrown. Server-side validation is now performed, " +
26+
"resulting in a GoogleApiException with a 400 (Bad Request) status code on failure.")]
2527
public sealed class UploadValidationException : IOException
2628
{
2729
/// <summary>

0 commit comments

Comments
 (0)