[2020-04-07T11:22:52.141579336Z][instance:web1] Traceback (most recent call last):
[2020-04-07T11:22:52.141659427Z][instance:web1] File "/usr/share/pyenv/versions/3.7.3/lib/python3.7/site-packages/leancloud/engine/leanengine.py", line 146, in dispatch_request
[2020-04-07T11:22:52.141669067Z][instance:web1] return Response(json.dumps(result), mimetype='application/json')
[2020-04-07T11:22:52.141673337Z][instance:web1] File "/usr/share/pyenv/versions/3.7.3/lib/python3.7/json/__init__.py", line 231, in dumps
[2020-04-07T11:22:52.141677748Z][instance:web1] return defaultencoder.encode(obj)
[2020-04-07T11:22:52.141681748Z][instance:web1] File "/usr/share/pyenv/versions/3.7.3/lib/python3.7/json/encoder.py", line 199, in encode
[2020-04-07T11:22:52.141685608Z][instance:web1] chunks = self.iterencode(o, oneshot=True)
[2020-04-07T11:22:52.141689332Z][instance:web1] File "/usr/share/pyenv/versions/3.7.3/lib/python3.7/json/encoder.py", line 257, in iterencode
[2020-04-07T11:22:52.141693117Z][instance:web1] return _iterencode(o, 0)
[2020-04-07T11:22:52.144632603Z][instance:web1] File "/usr/share/pyenv/versions/3.7.3/lib/python3.7/json/encoder.py", line 179, in default
[2020-04-07T11:22:52.144700584Z][instance:web1] raise TypeError(f'Object of type {o.class.name} '
[2020-04-07T11:22:52.144705646Z][instance:web1] TypeError: Object of type Conv is not JSON serializable

看起来是序列化碰到了问题,这里的 result 是什么样的对象?
方便提供下和 return Response(json.dumps(result), mimetype='application/json') 相关的代码吗?

我大概知道了,有个云引擎的函数 , 正常情况下返回查询到数据,有一些情况 没做返回,直接 pass 掉了,是用python写的,会是这个问题吗?
对返回的空对象,没法做序列化处理?

方便贴出可重现问题的代码吗?

def createConversation(convId, startUserId, targetUserId):
    leancloud.use_master_key()
    query = leancloud.Query('Conv')
    query.equal_to('convId', convId)
    convs = query.find()
    if convs:
        conv = convs[0]
        if conv.get('isDead') == True:
            conv.set('isDead', False)
            conv.save()
            return query.first()
        else:
            pass

云引擎的函数。
有点丑。。哈哈哈

可以试试在返回结果前先调用一下 dump 方法,也就是 return query.first().dump()

pass 部分也需要改下,比如改成返回一个空字典(return {}),不过最好还是根据业务需求抛一个 HTTP 异常。

好的,收到,我会调试下的,感谢~