Skip to content

Commit 24416a8

Browse files
Add comments linking to relevent docs
1 parent 0393a22 commit 24416a8

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

test/azure_blobs_exception_tests.jl

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@
152152
end
153153
end # @testitem
154154

155+
### See Azure Blob Storage docs: https://learn.microsoft.com/en-us/rest/api/storageservices
156+
### - "Common REST API error codes":
157+
### https://learn.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes
158+
### - "Azure Blob Storage error codes":
159+
### https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
160+
### - "Get Blob"
161+
### https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob
162+
### - "Put Blob"
163+
### https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob
155164
@testitem "BlobStorage retries" setup=[InitializeRustStore] begin
156165
using CloudBase.CloudTest: Azurite
157166
import CloudBase
@@ -198,11 +207,11 @@ end # @testitem
198207
return nrequests[]
199208
end
200209

201-
# See https://learn.microsoft.com/en-us/rest/api/searchservice/http-status-codes
202-
203210
@testset "400: Bad Request" begin
204211
# Returned when there's an error in the request URI, headers, or body. The response body
205212
# contains an error message explaining what the specific problem is.
213+
# See https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
214+
# See https://www.rfc-editor.org/rfc/rfc9110#status.400
206215
nrequests = test_status(:GET, 400)
207216
@test nrequests == 1
208217
nrequests = test_status(:PUT, 400)
@@ -211,18 +220,23 @@ end # @testitem
211220

212221
@testset "403: Forbidden" begin
213222
# Returned when you pass an invalid api-key.
223+
# See https://www.rfc-editor.org/rfc/rfc9110#status.403
214224
nrequests = test_status(:GET, 403)
215225
@test nrequests == 1
216226
nrequests = test_status(:PUT, 403)
217227
@test nrequests == 1
218228
end
219229

220230
@testset "404: Not Found" begin
231+
# Returned when container not found or blob not found
232+
# See https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
233+
# See https://www.rfc-editor.org/rfc/rfc9110#status.404
221234
nrequests = test_status(:GET, 404)
222235
@test nrequests == 1
223236
end
224237

225238
@testset "405: Method Not Supported" begin
239+
# See https://www.rfc-editor.org/rfc/rfc9110#status.405
226240
nrequests = test_status(:GET, 405, ["Allow" => "PUT"])
227241
@test nrequests == 1
228242
nrequests = test_status(:PUT, 405, ["Allow" => "GET"])
@@ -231,7 +245,9 @@ end # @testitem
231245

232246
@testset "409: Conflict" begin
233247
# Returned when write operations conflict.
234-
# NOTE: We currently don't retry but maybe we should? This is probably a case where the
248+
# See https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
249+
# See https://www.rfc-editor.org/rfc/rfc9110#status.409
250+
# TODO: We currently don't retry but maybe we should? This is probably a case where the
235251
# retry logic should add more noise to the backoff so that multiple writers don't collide on retry.
236252
nrequests = test_status(:GET, 409)
237253
@test nrequests == 1 + max_retries broken=true
@@ -241,22 +257,32 @@ end # @testitem
241257

242258
@testset "412: Precondition Failed" begin
243259
# Returned when an If-Match or If-None-Match header's condition evaluates to false
260+
# See https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob#blob-custom-properties
261+
# See https://www.rfc-editor.org/rfc/rfc9110#status.412
244262
nrequests = test_status(:GET, 412)
245263
@test nrequests == 1
246264
nrequests = test_status(:PUT, 412)
247265
@test nrequests == 1
248266
end
249267

250268
@testset "413: Content Too Large" begin
251-
# https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=shared-access-signatures#remarks
269+
# See https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob#remarks
270+
# If you attempt to upload either a block blob that's larger than the maximum
271+
# permitted size for that service version or a page blob that's larger than 8 TiB,
272+
# the service returns status code 413 (Request Entity Too Large). Blob Storage also
273+
# returns additional information about the error in the response, including the
274+
# maximum permitted blob size, in bytes.
275+
# See https://www.rfc-editor.org/rfc/rfc9110#status.413
252276
nrequests = test_status(:PUT, 413)
253277
@test nrequests == 1
254278
end
255279

256280
@testset "429: Too Many Requests" begin
281+
# See https://www.rfc-editor.org/rfc/rfc6585#section-4
282+
# See https://www.rfc-editor.org/rfc/rfc9110#field.retry-after
257283
# TODO: We probably should respect the Retry-After header, but we currently don't
258284
# (and we don't know if Azure actually sets it)
259-
# NOTE: This can happen when Azure is throttling us, so it might be a good idea to retry with some
285+
# This can happen when Azure is throttling us, so it might be a good idea to retry with some
260286
# larger initial backoff (very eager retries probably only make the situation worse).
261287
nrequests = test_status(:GET, 429, ["Retry-After" => 10])
262288
@test nrequests == 1 + max_retries broken=true
@@ -265,24 +291,42 @@ end # @testitem
265291
end
266292

267293
@testset "502: Bad Gateway" begin
268-
# This error occurs when you enter HTTP instead of HTTPS in the connection.
294+
# https://www.rfc-editor.org/rfc/rfc9110#status.502
295+
# The 502 (Bad Gateway) status code indicates that the server, while acting as a
296+
# gateway or proxy, received an invalid response from an inbound server it accessed
297+
# while attempting to fulfill the request.
298+
# This error can occur when you enter HTTP instead of HTTPS in the connection.
269299
nrequests = test_status(:GET, 502)
270300
@test nrequests == 1 broken=true
271301
nrequests = test_status(:PUT, 502)
272302
@test nrequests == 1 broken=true
273303
end
274304

275305
@testset "503: Service Unavailable" begin
276-
# NOTE: This seems similar to 429 and the Azure docs specifically say:
277-
# Important: In this case, we highly recommend that your client code back off and wait before retrying
306+
# See https://www.rfc-editor.org/rfc/rfc9110#status.503
307+
# The 503 (Service Unavailable) status code indicates that the server is currently
308+
# unable to handle the request due to a temporary overload or scheduled maintenance,
309+
# which will likely be alleviated after some delay. The server MAY send a Retry-After
310+
# header field (Section 10.2.3) to suggest an appropriate amount of time for the
311+
# client to wait before retrying the request.
312+
# See https://learn.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes
313+
# An operation on any of the Azure Storage services can return the following error codes:
314+
# Error code HTTP status code User message
315+
# ServerBusy Service Unavailable (503) The server is currently unable to receive requests. Please retry your request.
316+
# ServerBusy Service Unavailable (503) Ingress is over the account limit.
317+
# ServerBusy Service Unavailable (503) Egress is over the account limit.
318+
# ServerBusy Service Unavailable (503) Operations per second is over the account limit.
278319
nrequests = test_status(:GET, 503)
279320
@test nrequests == 1 + max_retries
280321
nrequests = test_status(:PUT, 503)
281322
@test nrequests == 1 + max_retries
282323
end
283324

284325
@testset "504: Gateway Timeout" begin
285-
# Azure AI Search listens on HTTPS port 443. If your search service URL contains HTTP instead of HTTPS, a 504 status code is returned.
326+
# See https://www.rfc-editor.org/rfc/rfc9110#status.504
327+
# The 504 (Gateway Timeout) status code indicates that the server, while acting as
328+
# a gateway or proxy, did not receive a timely response from an upstream server it
329+
# needed to access in order to complete the request
286330
nrequests = test_status(:GET, 504)
287331
@test nrequests == 1 broken=true
288332
nrequests = test_status(:PUT, 504)

0 commit comments

Comments
 (0)