← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rye/python-oops-datedir-repo/empty-oops into lp:python-oops-datedir-repo

 

Roman Yepishev has proposed merging lp:~rye/python-oops-datedir-repo/empty-oops into lp:python-oops-datedir-repo.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #894682 in Python OOPS Date-dir repository: "Crashes with bson error when oops is corrupted (zero bytes size)"
  https://bugs.launchpad.net/python-oops-datedir-repo/+bug/894682

For more details, see:
https://code.launchpad.net/~rye/python-oops-datedir-repo/empty-oops/+merge/83378

This checks for length of the oops content before sending it to serializers.
OOPSes of 0 sizes signal about the problem with serializer, but they should not prevent oops loader from working properly.
-- 
https://code.launchpad.net/~rye/python-oops-datedir-repo/empty-oops/+merge/83378
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rye/python-oops-datedir-repo/empty-oops into lp:python-oops-datedir-repo.
=== modified file 'oops_datedir_repo/serializer.py'
--- oops_datedir_repo/serializer.py	2011-11-11 04:21:05 +0000
+++ oops_datedir_repo/serializer.py	2011-11-25 09:30:28 +0000
@@ -48,6 +48,11 @@
     """
     # Deal with no-rewindable file pointers.
     content = fp.read()
+
+    if len(content) == 0:
+        # This OOPS has no content
+        raise IOError("Empty OOPS Report")
+
     try:
         return serializer_bson.read(StringIO(content))
     except KeyError:

=== modified file 'oops_datedir_repo/tests/test_serializer.py'
--- oops_datedir_repo/tests/test_serializer.py	2011-11-11 04:48:09 +0000
+++ oops_datedir_repo/tests/test_serializer.py	2011-11-25 09:30:28 +0000
@@ -67,3 +67,8 @@
         source_file.write(dumps(dict(self.source_dict)))
         source_file.seek(0)
         self.assertEqual(self.expected_dict, read(source_file))
+
+    def test_ioerror_on_empty_oops(self):
+        source_file = StringIO.StringIO()
+        self.assertRaises(IOError, read, source_file)
+