)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},"change_message_id":"8957cb039d9647bbb713671786626d8073104cff","unresolved":false,"context_lines":[{"line_number":7,"context_line":"fix: the creds params doesn\u0027t check dict type"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"In the Enforcer.enforce or Enforcer.authorize function, when using"},{"line_number":10,"context_line":"a dictionary in the case of the cerds parameter, will get"},{"line_number":11,"context_line":"an InvalidContextObject Exception."},{"line_number":12,"context_line":"The message prompts that you should use \"RequestContext\", \"dict\" or"},{"line_number":13,"context_line":"the output of \"RequestContext.to_policy_values\", dict type should pass,"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"1f621f24_f529068a","line":10,"range":{"start_line":10,"start_character":32,"end_line":10,"end_character":37},"updated":"2020-11-09 09:31:11.000000000","message":"creds","commit_id":"ca5299127690d3e3b35b0389de1b795ac69bba47"},{"author":{"_account_id":27809,"name":"hanxiang gao","email":"gaohanxiang@126.com","username":"gao.hanxiang"},"change_message_id":"f79948c9332fcd59ed65ddba28360c3aee94b8fc","unresolved":false,"context_lines":[{"line_number":7,"context_line":"fix: the creds params doesn\u0027t check dict type"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"In the Enforcer.enforce or Enforcer.authorize function, when using"},{"line_number":10,"context_line":"a dictionary in the case of the cerds parameter, will get"},{"line_number":11,"context_line":"an InvalidContextObject Exception."},{"line_number":12,"context_line":"The message prompts that you should use \"RequestContext\", \"dict\" or"},{"line_number":13,"context_line":"the output of \"RequestContext.to_policy_values\", dict type should pass,"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"1f621f24_0feaabaa","line":10,"range":{"start_line":10,"start_character":32,"end_line":10,"end_character":37},"in_reply_to":"1f621f24_f529068a","updated":"2020-11-09 16:15:47.000000000","message":"Done","commit_id":"ca5299127690d3e3b35b0389de1b795ac69bba47"}],"oslo_policy/policy.py":[{"author":{"_account_id":28522,"name":"Hervé Beraud","email":"herveberaud.pro@gmail.com","username":"hberaud"},"change_message_id":"8957cb039d9647bbb713671786626d8073104cff","unresolved":false,"context_lines":[{"line_number":923,"context_line":""},{"line_number":924,"context_line":"        self.load_rules()"},{"line_number":925,"context_line":""},{"line_number":926,"context_line":"        if isinstance(creds, context.RequestContext):"},{"line_number":927,"context_line":"            creds \u003d self._map_context_attributes_into_creds(creds)"},{"line_number":928,"context_line":"        # NOTE(lbragstad): The oslo.context library exposes the ability to call"},{"line_number":929,"context_line":"        # a method on RequestContext objects that converts attributes of the"}],"source_content_type":"text/x-python","patch_set":1,"id":"1f621f24_35db7e4f","line":926,"range":{"start_line":926,"start_character":29,"end_line":926,"end_character":51},"updated":"2020-11-09 09:31:11.000000000","message":"If you want to avoid the exception below I think the dict type should be added above.\n\nIn the `elif` clause we already failed and this is when the exception will be raised, in other words it\u0027s too late.\n\nThoughts?","commit_id":"ca5299127690d3e3b35b0389de1b795ac69bba47"},{"author":{"_account_id":27809,"name":"hanxiang gao","email":"gaohanxiang@126.com","username":"gao.hanxiang"},"change_message_id":"f79948c9332fcd59ed65ddba28360c3aee94b8fc","unresolved":false,"context_lines":[{"line_number":923,"context_line":""},{"line_number":924,"context_line":"        self.load_rules()"},{"line_number":925,"context_line":""},{"line_number":926,"context_line":"        if isinstance(creds, context.RequestContext):"},{"line_number":927,"context_line":"            creds \u003d self._map_context_attributes_into_creds(creds)"},{"line_number":928,"context_line":"        # NOTE(lbragstad): The oslo.context library exposes the ability to call"},{"line_number":929,"context_line":"        # a method on RequestContext objects that converts attributes of the"}],"source_content_type":"text/x-python","patch_set":1,"id":"1f621f24_2f97a73c","line":926,"range":{"start_line":926,"start_character":29,"end_line":926,"end_character":51},"in_reply_to":"1f621f24_35db7e4f","updated":"2020-11-09 16:15:47.000000000","message":"Thanks for your review. Perhaps the correct logic should be:\n\n```\nif isinstance(creds, context.RequestContext):\n     creds \u003d handle_context_into_creds(creds)\nelif isinstance(creds, (collections.MutableMapping, dict)):\n     # Do nothing\n     pass\nelse:\n     raise exception\n```\n\nThe concise code is:\n\n```\nif isinstance(creds, context.RequestContext):\n     creds \u003d handle_context_into_creds()\nelif not isinstance(creds, (collections.MutableMapping, dict)):\n     raise exception\n```","commit_id":"ca5299127690d3e3b35b0389de1b795ac69bba47"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"3f48bd2d88096af1b6b4cfd38d69b18ffd8ce164","unresolved":true,"context_lines":[{"line_number":931,"context_line":"        # doesn\u0027t actually return a dictionary, it\u0027s a subclass of"},{"line_number":932,"context_line":"        # collections.MutableMapping, which behaves like a dictionary but"},{"line_number":933,"context_line":"        # doesn\u0027t pass the type check."},{"line_number":934,"context_line":"        elif not isinstance(creds, (collections.MutableMapping, dict)):"},{"line_number":935,"context_line":"            msg \u003d ("},{"line_number":936,"context_line":"                \u0027Expected type oslo_context.context.RequestContext, dict, or \u0027"},{"line_number":937,"context_line":"                \u0027the output of \u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"567d7e3d_9a24e716","line":934,"updated":"2021-04-21 15:39:49.000000000","message":"I think this is correct as-is:\n\n  \u003e\u003e\u003e import collections.abc\n  \u003e\u003e\u003e x \u003d {\u0027a\u0027: 123}\n  \u003e\u003e\u003e isinstance(x, collections.abc.MutableMapping)\n  True","commit_id":"6bc994f7051e9dd089e1bcc34e680872ecee838e"}]}
