Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
bug: Make error responses more unique to assist in production debugging
Browse files Browse the repository at this point in the history
Closes #1087
  • Loading branch information
jrconlin committed Dec 1, 2017
1 parent e4503d5 commit 55efc80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions autopush/tests/test_web_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def test_no_current_month(self):

assert cm.value.status_code == 410
assert cm.value.errno == 106
assert cm.value.message == "No such subscription"
assert cm.value.message == "Subscription elapsed"

def test_old_current_month(self):
schema = self._make_fut()
Expand All @@ -616,7 +616,7 @@ def test_old_current_month(self):

assert cm.value.status_code == 410
assert cm.value.errno == 106
assert cm.value.message == "No such subscription"
assert cm.value.message == "Subscription expired"


class TestWebPushRequestSchemaUsingVapid(unittest.TestCase):
Expand Down
5 changes: 3 additions & 2 deletions autopush/web/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def validate_auth(self, data):
auth_type, auth_token = re.sub(
r' +', ' ', auth.strip()).split(" ", 2)
except ValueError:
raise InvalidRequest("Invalid Authentication", status_code=401,
raise InvalidRequest("Invalid Authentication",
status_code=401,
errno=109,
headers=request_pref_header)
if auth_type.lower() not in AUTH_SCHEMES:
Expand Down Expand Up @@ -483,4 +484,4 @@ def _chid_not_found_err(self, fail):
self.log.debug(format="CHID not found in AWS.",
status_code=410, errno=106,
**self._client_info)
self._write_response(410, 106, message="Invalid endpoint.")
self._write_response(410, 106, message="Invalid endpoint for user.")
12 changes: 8 additions & 4 deletions autopush/web/webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def validate_uaid_month_and_chid(self, d):
self.context["metrics"].increment("updates.drop_user",
tags=make_tags(errno=102))
self.context["db"].router.drop_user(result["uaid"])
raise InvalidRequest("No such subscription", status_code=410,
raise InvalidRequest("No route for subscription",
status_code=410,
errno=106)

if (router_type in ["gcm", "fcm"]
Expand Down Expand Up @@ -137,7 +138,8 @@ def _validate_webpush(self, d, result):
uaid_record=repr(result))
metrics.increment("updates.drop_user", tags=make_tags(errno=102))
db.router.drop_user(uaid)
raise InvalidRequest("No such subscription", status_code=410,
raise InvalidRequest("Subscription elapsed",
status_code=410,
errno=106)

month_table = result["current_month"]
Expand All @@ -147,15 +149,17 @@ def _validate_webpush(self, d, result):
uaid_record=repr(result))
metrics.increment("updates.drop_user", tags=make_tags(errno=103))
db.router.drop_user(uaid)
raise InvalidRequest("No such subscription", status_code=410,
raise InvalidRequest("Subscription expired",
status_code=410,
errno=106)
exists, chans = db.message_tables[month_table].all_channels(uaid=uaid)

if (not exists or channel_id.lower() not
in map(lambda x: normalize_id(x), chans)):
log.debug("Unknown subscription: {channel_id}",
channel_id=channel_id)
raise InvalidRequest("No such subscription", status_code=410,
raise InvalidRequest("No such subscription for user",
status_code=410,
errno=106)


Expand Down

0 comments on commit 55efc80

Please sign in to comment.