Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 87c9580

Browse files
committed
Improve HTTP failure messages
1 parent b16ba85 commit 87c9580

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

swift_upload_runner/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async def handle_get_object_chunk(
132132
# thus, reducing said 1 from the resulting chunk number
133133
chunk_number = int(request.query["resumableChunkNumber"]) - 1
134134
except KeyError:
135-
raise aiohttp.web.HTTPBadRequest(reason="Malformed query string.")
135+
raise aiohttp.web.HTTPBadRequest(reason="Malformed query string")
136136

137137
upload_session = await get_upload_instance(
138138
request,

swift_upload_runner/auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def handle_validate_authentication(
9898
path = request.url.path
9999
except KeyError:
100100
raise aiohttp.web.HTTPUnauthorized(
101-
reason="Query string missing validity or signature."
101+
reason="Query string missing validity or signature"
102102
)
103103

104104
await test_signature(

swift_upload_runner/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def get_session_id(
4949
return request.query["session"]
5050
except KeyError:
5151
raise aiohttp.web.HTTPUnauthorized(
52-
reason="Runner session ID missing"
52+
reason="Missing runner session ID"
5353
)
5454

5555

@@ -110,7 +110,7 @@ async def get_upload_instance(
110110
try:
111111
ident = query["resumableIdentifier"]
112112
except KeyError:
113-
raise aiohttp.web.HTTPBadRequest(reason="Malformed query string.")
113+
raise aiohttp.web.HTTPBadRequest(reason="Malformed query string")
114114
try:
115115
upload_session = request.app[session]["uploads"][pro][cont][ident]
116116
except KeyError:

swift_upload_runner/download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def _parse_archive_fs(
341341
print(path)
342342
# Path of zero means an incorrect input
343343
if len(path) == 0:
344-
raise ValueError("Can't archive files without name.")
344+
raise ValueError("Tried to archive a file wihtout a name")
345345
# Path of > 1 implies a directory in between
346346
# Create TarInfo for the directory
347347
if len(path) > 1:

swift_upload_runner/replicate.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def a_create_container(
8585
) as resp:
8686
if resp.status not in {201, 202}:
8787
raise aiohttp.web.HTTPForbidden(
88-
reason="Can't create the upload container."
88+
reason="Upload container creation failed"
8989
)
9090
LOGGER.debug(f"Created container {container}")
9191

@@ -107,11 +107,11 @@ async def a_sync_object_segments(
107107
) as resp:
108108
if resp.status == 404:
109109
raise aiohttp.web.HTTPNotFound(
110-
reason="Couldn't find segment container."
110+
reason="Segment container not found"
111111
)
112112
if resp.status == 403:
113113
raise aiohttp.web.HTTPForbidden(
114-
reason="Not allowed to access segment container."
114+
reason="Segment container access not allowed"
115115
)
116116
prefix = manifest.replace(manifest.split('/')[0], "").lstrip('/')
117117
LOGGER.debug(f"Segment prefix: {prefix}")
@@ -149,7 +149,7 @@ async def a_sync_object_segments(
149149

150150
if resp_g.status not in {200, 201, 202}:
151151
raise aiohttp.web.HTTPNotFound(
152-
reason="Couldn't find segment"
152+
reason="Segment not found"
153153
)
154154
LOGGER.debug(f"Copying segment {segment}")
155155
headers["Content-Length"] = str(length)
@@ -173,7 +173,7 @@ async def a_sync_object_segments(
173173
raise aiohttp.web.HTTPRequestTimeout()
174174
if resp_p.status not in {201, 202}:
175175
raise aiohttp.web.HTTPBadRequest(
176-
reason="Couldn't upload object segment"
176+
reason="Segment upload failed"
177177
)
178178
LOGGER.debug(f"Success in copying segment {segment}")
179179

@@ -202,7 +202,7 @@ async def a_copy_object(
202202
# If the source object doesn't exist, abort
203203
if resp_g.status != 200:
204204
raise aiohttp.web.HTTPBadRequest(
205-
reason="Couldn't fetch the source object."
205+
reason="Source object fetch failed"
206206
)
207207
LOGGER.debug(f"Got stream handle for {object_name}")
208208

@@ -242,7 +242,7 @@ async def a_copy_object(
242242
raise aiohttp.web.HTTPRequestTimeout()
243243
if resp_p.status not in {201, 202}:
244244
raise aiohttp.web.HTTPBadRequest(
245-
reason="Couldn't upload object segment"
245+
reason="Object segment upload failed"
246246
)
247247
LOGGER.debug(f"Success in copying object {object_name}")
248248
else:
@@ -271,7 +271,7 @@ async def a_copy_object(
271271
) as resp:
272272
if resp.status != 201:
273273
raise aiohttp.web.HTTPInternalServerError(
274-
reason="Manifest creation failure."
274+
reason="Object manifest creation failed"
275275
)
276276
LOGGER.debug(f"Uploaded manifest for {object_name}")
277277

@@ -300,7 +300,7 @@ async def a_copy_from_container(self):
300300
f"Container fetch failed with status {resp.status}"
301301
)
302302
raise aiohttp.web.HTTPBadRequest(
303-
reason="Couldn't fetch the source container"
303+
reason="Source container fetch failed"
304304
)
305305
LOGGER.debug("Got container object listing")
306306
objects = await resp.text()

swift_upload_runner/upload.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async def a_create_container(
124124
) as resp:
125125
if resp.status not in {201, 202}:
126126
raise aiohttp.web.HTTPForbidden(
127-
reason="Can't create the upload container."
127+
reason="Upload container creation failed"
128128
)
129129

130130
async def a_check_container(

0 commit comments

Comments
 (0)