Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-219

KeyError in find_and_modify

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.10
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      pymongo 1.9 on linux, mongo 1.7.6

      error occured when using sharded table and issuing find_and_modify to a nonexisting key

      Traceback (most recent call last):
      File "/service/dbconnector/dbconnector.py", line 36, in eval_cmd
      res = eval_expr(block, variables)
      File "/service/dbconnector/dbconnector.py", line 29, in eval_expr
      return eval(expr,

      {"__builtins__":None}

      , variables )
      File "<string>", line 1, in <module>
      File "/service/dbconnector/dbmodules.py", line 417, in call_ended
      return find_token(connectionToken)
      File "/service/dbconnector/dbmodules.py", line 383, in find_token
      callstate = mdb.callstate.find_and_modify(query=

      {CS_TOKEN:connectionToken}

      , remove=True)
      File "build/bdist.linux-x86_64/egg/pymongo/collection.py", line 1009, in find_and_modify
      return out['value']
      KeyError: 'value'

      > db.callstate.stats()
      {
      "sharded" : true,
      "ns" : "db.callstate",
      "count" : 0,
      "size" : 0,
      "avgObjSize" : NaN,
      "storageSize" : 8192,
      "nindexes" : 1,
      "nchunks" : 1,
      "shards" : {
      "set1" : {
      "ns" : "db.callstate",
      "count" : 0,
      "size" : 0,
      "storageSize" : 8192,
      "numExtents" : 1,
      "nindexes" : 1,
      "lastExtentSize" : 8192,
      "paddingFactor" : 1,
      "flags" : 1,
      "totalIndexSize" : 8192,
      "indexSizes" :

      { "_id_" : 8192 }

      ,
      "ok" : 1
      }
      },
      "ok" : 1
      }
      >

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            ofersa ofer samocha
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: