From: Alexander Turenko <alexander.turenko@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] Re: [PATCH v2 4/4] app: allow to raise an error on too nested tables Date: Fri, 13 Sep 2019 02:32:32 +0300 [thread overview] Message-ID: <20190912233231.zs3c6o2zv7pyl6lo@tkn_work_nb> (raw) In-Reply-To: <c9a04a6bdf8752dce051c264edfe097ba85d2bda.1568055477.git.v.shpilevoy@tarantool.org> > app: allow to raise an error on too nested tables The commit header and the description looks like we have 'crop' behaviour as default, however it is not more so. I agree that we should change the default behaviour and raise an error by default. This however should be clearly stated in the docbot request. See more comments below. WBR, Alexander Turenko. > msgpack.cfg({encode_crop_too_deep = false}) We have encode_invalid_as_nil with the similar meanings, so, maybe, encode_too_deep_as_nil? Or maybe rephrase 'too deep' as one word: foots, dregs, underside? Those variants don't look good, but maybe you know some word that would fit better. > + if (! cfg->encode_crop_too_deep) > + return luaL_error(L, "Too high nest level"); We can easily give more information: say, a current max depth level; so I think it worth to add to the error message. (The same for msgpackffi and json.) > + -- gh-4434 (yes, the same issue): let users choose whether > + -- they want to raise an error on tables with too high nest > + -- level. > + -- > + s.cfg({encode_crop_too_deep = false}) > + > + local t = nil > + for i = 1, max_depth + 1 do t = {t} end > + local ok, err = pcall(s.encode, t) > + test:ok(not ok, "too deep encode depth") > + > + s.cfg({encode_max_depth = max_depth + 1}) > + ok, err = pcall(s.encode, t) > + test:ok(ok, "no throw in a corner case") > + > + s.cfg({encode_crop_too_deep = true, encode_max_depth = max_depth}) I think we should save a default value of the option and set it here as we do with encode_max_depth. (The same for msgpackffi.test.lua.) BTW, the default is 'false' and we should set the default value here (now we set 'true'). Following test cases (e.g. gh-2888 test case in app-tap/json.test.lua) should set and restore the option locally. Maybe it also worth add a test case that will verify that the default behaviour is to raise an error?
next prev parent reply other threads:[~2019-09-12 23:32 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-10 20:24 [tarantool-patches] [PATCH v2 0/4] Serializer bugs Vladislav Shpilevoy 2019-09-09 19:00 ` [tarantool-patches] [PATCH v2 1/4] app: serializers update now is reflected in Lua Vladislav Shpilevoy 2019-09-12 23:22 ` [tarantool-patches] " Alexander Turenko 2019-09-13 22:32 ` Vladislav Shpilevoy 2019-09-09 19:00 ` [tarantool-patches] [PATCH v2 2/4] msgpack: make msgpackffi use encode_max_depth option Vladislav Shpilevoy 2019-09-12 23:24 ` [tarantool-patches] " Alexander Turenko 2019-09-13 22:32 ` Vladislav Shpilevoy 2019-09-09 19:00 ` [tarantool-patches] [PATCH v2 3/4] tuple: use global msgpack serializer in Lua tuple Vladislav Shpilevoy 2019-09-12 23:27 ` [tarantool-patches] " Alexander Turenko 2019-09-13 22:32 ` Vladislav Shpilevoy 2019-09-09 19:00 ` [tarantool-patches] [PATCH v2 4/4] app: allow to raise an error on too nested tables Vladislav Shpilevoy 2019-09-12 23:32 ` Alexander Turenko [this message] 2019-09-13 22:32 ` [tarantool-patches] " Vladislav Shpilevoy 2019-09-10 20:25 ` [tarantool-patches] Re: [PATCH v2 0/4] Serializer bugs Vladislav Shpilevoy 2019-09-12 23:44 ` Alexander Turenko 2019-09-13 22:32 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190912233231.zs3c6o2zv7pyl6lo@tkn_work_nb \ --to=alexander.turenko@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='[tarantool-patches] Re: [PATCH v2 4/4] app: allow to raise an error on too nested tables' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox