neo4j-contrib / neo4j_doc_manager

Doc manager for Neo4j
Apache License 2.0
99 stars 26 forks source link

Neo4jOperationFailed: Object of type 'ObjectId' is not JSON serializable #66

Closed AyWa closed 7 years ago

AyWa commented 7 years ago

Hi guys,

I have this error while the mongo_connector is duplicating data. ( it is working for almost all my data but it's throwing an error for this one. Do you have anyidea or fixing it ?

2017-01-09 11:38:52,049 [ALWAYS] mongo_connector.connector:52 - Starting mongo-connector version: 2.5.0
2017-01-09 11:38:52,050 [ALWAYS] mongo_connector.connector:52 - Python version: 3.6.0 (default, Dec 28 2016, 23:09:0
[GCC 4.9.2]
2017-01-09 11:38:52,051 [ALWAYS] mongo_connector.connector:52 - Platform: Linux-4.4.0-57-generic-x86_64-with-debian-
2017-01-09 11:38:52,051 [ALWAYS] mongo_connector.connector:52 - pymongo version: 3.4.0
2017-01-09 11:38:52,643 [ALWAYS] mongo_connector.connector:52 - Source MongoDB version: 3.4.1
2017-01-09 11:38:52,643 [ALWAYS] mongo_connector.connector:52 - Target DocManager: mongo_connector.doc_managers.neo4
2017-01-09 11:45:13,278 [ERROR] mongo_connector.oplog_manager:288 - Unable to process oplog document {'ts': Timestam
c25876641d4c705a94')}, 'o': {'$set': {'friends.accepted': [{'dateAccepted': datetime.datetime(2017, 1, 9, 11, , 45, 13, 833000), '_id': ObjectId('587377c95876641d4c705a97'), 'users_id': ObjectId('587377c95876641d4c705a95')}]}}}
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/mongo_connector/util.py", line 33, in wrapped
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/mongo_connector/doc_managers/neo4j_doc_manager.py", line 101, in upda
    tx.commit()
  File "/usr/local/lib/python3.6/site-packages/py2neo/cypher/core.py", line 333, in commit
    return self.post(self.__commit or self.__begin_commit)
  File "/usr/local/lib/python3.6/site-packages/py2neo/cypher/core.py", line 275, in post
    rs = resource.post({"statements": self.statements})
  File "/usr/local/lib/python3.6/site-packages/py2neo/core.py", line 307, in post
    response = self.__base.post(body, headers, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/py2neo/packages/httpstream/http.py", line 983, in post
    rq = Request("POST", self.uri, body, headers)
  File "/usr/local/lib/python3.6/site-packages/py2neo/packages/httpstream/http.py", line 382, in __init__
    self.__body = json.dumps(body, cls=JSONEncoder, separators=",:")
  File "/usr/local/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/local/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.6/site-packages/py2neo/packages/httpstream/jsonencoder.py", line 37, in default
    return json.JSONEncoder.default(self, obj)
  File "/usr/local/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'ObjectId' is not JSON serializable
simonthme commented 6 years ago

Hello @AyWa , I've got the same error and I don't really know how to solve it... Have you had success with it ? Thanks

AyWa commented 6 years ago

@simonthme Hello, I am sorry, this issue happens more than one years ago for a school project, So I don't really remember if we found a work arround or not.