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

Commit

Permalink
bug: Clear corrupted router records
Browse files Browse the repository at this point in the history
Records containing only a UAID are corrupt. Drop these records and
return a 410 to the server.

Closes #400
  • Loading branch information
jrconlin committed Mar 12, 2016
1 parent a543105 commit df70829
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion autopush/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,13 @@ 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']:
import pdb; pdb.set_trace()
# 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 df70829

Please sign in to comment.