You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/04/03 23:00:55 UTC
git commit: [#7307] safer 'doc too large' checking,
to account for ming's arg injection
Repository: allura
Updated Branches:
refs/heads/db/7307 [created] 8ec2e2fb5
[#7307] safer 'doc too large' checking, to account for ming's arg injection
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/8ec2e2fb
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8ec2e2fb
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8ec2e2fb
Branch: refs/heads/db/7307
Commit: 8ec2e2fb53accc4541b350499ba8462dc77e04c7
Parents: f72b7fd
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Apr 3 15:21:13 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Apr 3 15:25:27 2014 +0000
----------------------------------------------------------------------
Allura/allura/command/show_models.py | 2 +-
Allura/allura/model/session.py | 2 +-
Allura/allura/tests/test_commands.py | 5 ++++-
Allura/allura/tests/unit/test_session.py | 5 ++++-
4 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/8ec2e2fb/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index 76d95ac..36aa29e 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -177,7 +177,7 @@ class ReindexCommand(base.Command):
except InvalidDocument as e:
# there are many types of InvalidDocument, only recurse if its
# expected to help
- if str(e).startswith('BSON document too large'):
+ if e.args[0].startswith('BSON document too large'):
self._post_add_artifacts(chunk[:len(chunk) // 2])
self._post_add_artifacts(chunk[len(chunk) // 2:])
else:
http://git-wip-us.apache.org/repos/asf/allura/blob/8ec2e2fb/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 50bbb8a..ca5db5a 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -162,7 +162,7 @@ class BatchIndexer(ArtifactSessionExtension):
except pymongo.errors.InvalidDocument as e:
# there are many types of InvalidDocument, only recurse if its
# expected to help
- if str(e).startswith('BSON document too large'):
+ if e.args[0].startswith('BSON document too large'):
cls._post(task_func, chunk[:len(chunk) // 2])
cls._post(task_func, chunk[len(chunk) // 2:])
else:
http://git-wip-us.apache.org/repos/asf/allura/blob/8ec2e2fb/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 1ecfb39..73b419a 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -442,8 +442,11 @@ class TestReindexCommand(object):
def test_post_add_artifacts_too_large(self, add_artifacts):
def on_post(chunk, **kw):
if len(chunk) > 1:
- raise pymongo.errors.InvalidDocument(
+ e = pymongo.errors.InvalidDocument(
"BSON document too large (16906035 bytes) - the connected server supports BSON document sizes up to 16777216 bytes.")
+ # ming injects a 2nd arg with the document, so we do too
+ e.args = e.args + ("doc: {'task_name': 'allura.tasks.index_tasks.add_artifacts', ........",)
+ raise e
add_artifacts.post.side_effect = on_post
cmd = show_models.ReindexCommand('reindex')
cmd.options, args = cmd.parser.parse_args([])
http://git-wip-us.apache.org/repos/asf/allura/blob/8ec2e2fb/Allura/allura/tests/unit/test_session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_session.py b/Allura/allura/tests/unit/test_session.py
index f9bd277..eec41bd 100644
--- a/Allura/allura/tests/unit/test_session.py
+++ b/Allura/allura/tests/unit/test_session.py
@@ -142,8 +142,11 @@ class TestBatchIndexer(TestCase):
def test__post_too_large(self, index_tasks):
def on_post(chunk):
if len(chunk) > 1:
- raise pymongo.errors.InvalidDocument(
+ e = pymongo.errors.InvalidDocument(
"BSON document too large (16906035 bytes) - the connected server supports BSON document sizes up to 16777216 bytes.")
+ # ming injects a 2nd arg with the document, so we do too
+ e.args = e.args + ("doc: {'task_name': 'allura.tasks.index_tasks.add_artifacts', ........",)
+ raise e
index_tasks.add_artifacts.post.side_effect = on_post
self.ext._post(index_tasks.add_artifacts, range(5))
expected = [