InvalidJSON on valid json when dict expected.

Bug #1061109 reported by Lucio Torre
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
U1DB
Fix Released
Low
Unassigned

Bug Description

Trying to create a document with db.create_doc and using a valid json string as the content produces an "InvalidJSON" error:

>>> import u1db
>>> db = u1db.open(":memory:", create=True)
>>> db.create_doc("{}")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lucio/canonical/dedit/trunk/u1db-env/local/lib/python2.7/site-packages/u1db/backends/__init__.py", line 94, in create_doc
    doc = self._factory(doc_id, None, json_string)
  File "/home/lucio/canonical/dedit/trunk/u1db-env/local/lib/python2.7/site-packages/u1db/__init__.py", line 527, in __init__
    super(Document, self).__init__(doc_id, rev, json, has_conflicts)
  File "/home/lucio/canonical/dedit/trunk/u1db-env/local/lib/python2.7/site-packages/u1db/__init__.py", line 423, in __init__
    raise InvalidJSON
u1db.errors.InvalidJSON

Looking at the code, i see that backends/__init__.py:CommonBackend.create_doc forces the conversion to json and does not check if the input content is a dict.

Related branches

Changed in u1db:
assignee: nobody → Eric Casteleijn (thisfred)
Changed in u1db:
status: New → Triaged
importance: Undecided → Low
Changed in u1db:
status: Triaged → Fix Committed
Changed in u1db:
assignee: Eric Casteleijn (thisfred) → nobody
dobey (dobey)
Changed in u1db:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.