[错误报告] 在 SaveHandler 中在无效的 /save 数据包中发生了未捕获的 KeyError 和 AttributeError (HTTP 500)
作者: rishi919-rgb创建于 2026年9月22日更新于 2026年9月22日
Bug Description
During testing the environment persistence endpoints, I noticed that SaveHandler (/save) crashes with an unhandled exception (HTTP 500) when receiving malformed JSON, non-object JSON bodies, bodies without the "data" key, or non-string entries in "data".
In py/visdom/server/handlers/web_handlers.py:731-747:
class SaveHandler(BaseHandler):
@staticmethod
async def wrap_func(handler, args):
envs = args["data"]
envs = [escape_eid(eid) for eid in envs]
ret = await save_envs_off_loop(handler, envs)
handler.write(json.dumps(ret))
@check_auth
@check_readonly
async def post(self):
args = tornado.escape.json_decode(
tornado.escape.to_basestring(self.request.body)
)
await self.wrap_func(self, args)- Non-JSON body:
tornado.escape.json_decoderaisesValueError-> uncaught HTTP 500. - Non-mapping body (e.g.
[1, 2]):args["data"]raisesTypeError-> uncaught HTTP 500. - Missing
"data"key (e.g.{}):args["data"]raisesKeyError: 'data'-> uncaught HTTP 500. - Non-list
"data"(e.g.{"data": 123}or{"data": None}): raisesTypeError-> uncaught HTTP 500. - Non-string elements in
"data"(e.g.{"data": [123]}):escape_eidraisesAttributeError: 'int' object has no attribute 'strip'-> uncaught HTTP 500.
内容来源: fossasia/visdom