Skip to content

Commit e8f2fe0

Browse files
committed
Remove Oops error for character out of range - the error doesn't seem to happen now
1 parent ae09379 commit e8f2fe0

File tree

3 files changed

+3
-89
lines changed

3 files changed

+3
-89
lines changed

src/mock_vws/_services_validators/exceptions.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import uuid
88
from collections.abc import Mapping
99
from http import HTTPStatus
10-
from pathlib import Path
1110

1211
from beartype import beartype
1312

@@ -265,48 +264,6 @@ def __init__(self) -> None:
265264
}
266265

267266

268-
@beartype
269-
class OopsErrorOccurredResponseError(ValidatorError):
270-
"""Exception raised when VWS returns an HTML page which says "Oops, an
271-
error occurred".
272-
273-
This has been seen to happen when the given name includes a bad
274-
character.
275-
"""
276-
277-
def __init__(self) -> None:
278-
"""
279-
Attributes:
280-
status_code: The status code to use in a response if this is
281-
raised.
282-
response_text: The response text to use in a response if this is
283-
raised.
284-
"""
285-
super().__init__()
286-
self.status_code = HTTPStatus.INTERNAL_SERVER_ERROR
287-
resources_dir = Path(__file__).parent.parent / "resources"
288-
filename = "oops_error_occurred_response.html"
289-
oops_resp_file = resources_dir / filename
290-
text = str(object=oops_resp_file.read_text())
291-
self.response_text = text
292-
date = email.utils.formatdate(
293-
timeval=None,
294-
localtime=False,
295-
usegmt=True,
296-
)
297-
self.headers = {
298-
"Connection": "keep-alive",
299-
"Content-Type": "text/html; charset=UTF-8",
300-
"server": "envoy",
301-
"Date": date,
302-
"x-envoy-upstream-service-time": "5",
303-
"Content-Length": str(object=len(self.response_text)),
304-
"strict-transport-security": "max-age=31536000",
305-
"x-aws-region": "us-east-2, us-west-2",
306-
"x-content-type-options": "nosniff",
307-
}
308-
309-
310267
@beartype
311268
class BadImageError(ValidatorError):
312269
"""

src/mock_vws/_services_validators/name_validators.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from mock_vws._database_matchers import get_database_matching_server_keys
1313
from mock_vws._services_validators.exceptions import (
1414
FailError,
15-
OopsErrorOccurredResponseError,
1615
TargetNameExistError,
1716
)
1817
from mock_vws.database import VuforiaDatabase
@@ -35,8 +34,8 @@ def validate_name_characters_in_range(
3534
request_path: The path to the endpoint.
3635
3736
Raises:
38-
OopsErrorOccurredResponseError: Characters are out of range and the
39-
request is trying to make a new target.
37+
FailError: Characters are out of range and the request is trying to
38+
make a new target.
4039
TargetNameExistError: Characters are out of range and the request is
4140
for another endpoint.
4241
"""
@@ -55,7 +54,7 @@ def validate_name_characters_in_range(
5554

5655
if (request_method, request_path) == (HTTPMethod.POST, "/targets"):
5756
_LOGGER.warning(msg="Characters are out of range.")
58-
raise OopsErrorOccurredResponseError
57+
raise FailError(status_code=HTTPStatus.INTERNAL_SERVER_ERROR)
5958

6059
_LOGGER.warning(msg="Characters are out of range.")
6160
raise TargetNameExistError

src/mock_vws/resources/oops_error_occurred_response.html

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)