Skip to content

Commit

Permalink
Improve error reporting from stash
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham authored and SkyBlack1225 committed Nov 9, 2023
1 parent 0f0bf0d commit 1028817
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions resource-timing/resources/fake_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def main(request, response):
date = request.GET.first(b"date", b"")
modified = request.headers.get(b"If-Modified-Since", None)
url = request.GET.first(b"url", None)
response.headers.set(b"Access-Control-Allow-Origin", b"*");
response.headers.set(b"Timing-Allow-Origin", b"*");
response.headers.set(b"Access-Control-Allow-Origin", b"*")
response.headers.set(b"Timing-Allow-Origin", b"*")
if tag:
response.headers.set(b"ETag", b'"%s"' % tag)
elif date:
Expand All @@ -30,6 +30,7 @@ def main(request, response):
response.headers.set(b"Content-Type", b"text/javascript")
with open(filepath, 'rb') as f:
filedata = f.read()

return filedata

if ((match is not None and match == tag) or
Expand Down
6 changes: 5 additions & 1 deletion tools/wptserve/wptserve/stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ def _wrap_key(self, key, path):
if isinstance(key, bytes):
# UUIDs are within the ASCII charset.
key = key.decode('ascii')
return (isomorphic_encode(path), uuid.UUID(key).bytes)
try:
my_uuid = uuid.UUID(key).bytes
except ValueError as e:
raise ValueError(f"""Invalid UUID "{key}" used as stash key""") from e
return (isomorphic_encode(path), my_uuid)

def put(self, key, value, path=None):
"""Place a value in the shared stash.
Expand Down

0 comments on commit 1028817

Please sign in to comment.