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

Commit

Permalink
Merge pull request #403 from mozilla-services/bug/400
Browse files Browse the repository at this point in the history
bug: Clear corrupted router records
  • Loading branch information
jrconlin committed Mar 12, 2016
2 parents 3233302 + 5580e0d commit 004fa7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion autopush/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,12 @@ def get_uaid(self, uaid):
"""
try:
return self.table.get_item(consistent=True, uaid=hasher(uaid))
item = self.table.get_item(consistent=True, uaid=hasher(uaid))
if item.keys() == ['uaid']:
# Incomplete record, drop it.
self.drop_user(uaid)
raise ItemNotFound("uaid not found")
return item
except ProvisionedThroughputExceededException:
# We unfortunately have to catch this here, as track_provisioned
# will not see this, since JSONResponseError is a subclass and
Expand Down
9 changes: 9 additions & 0 deletions autopush/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,15 @@ def test_save_uaid(self):
eq_(bool(result), True)
eq_(result["node_id"], "me")

def test_incomplete_uaid(self):
uaid = str(uuid.uuid4())
r = get_router_table()
router = Router(r, SinkMetrics())
router.register_user(dict(uaid=uaid))
self.assertRaises(ItemNotFound, router.get_uaid, uaid)
self.assertRaises(ItemNotFound, router.table.get_item,
consistent=True, uaid=uaid)

def test_save_new(self):
r = get_router_table()
router = Router(r, SinkMetrics())
Expand Down

0 comments on commit 004fa7c

Please sign in to comment.