)]}'
{"monasca_api/v2/reference/alarm_definitions.py":[{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"7976e28b4b16560aa8200084288816dd30ebe9f7","unresolved":false,"context_lines":[{"line_number":268,"context_line":""},{"line_number":269,"context_line":"        description \u003d (alarm_definition_row[\u0027description\u0027]"},{"line_number":270,"context_line":"                       if alarm_definition_row[\u0027description\u0027] is not None else None)"},{"line_number":271,"context_line":"        if description and not isinstance(description, six.text_type):"},{"line_number":272,"context_line":"            description \u003d description.decode(\u0027utf8\u0027)"},{"line_number":273,"context_line":""},{"line_number":274,"context_line":"        expression \u003d alarm_definition_row[\u0027expression\u0027].decode(\u0027utf8\u0027)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3a71b18c_f73221a6","line":271,"updated":"2016-12-06 04:27:17.000000000","message":"I\u0027m just wondering when the description was not of test_type? The previous code never tested for a test_type, it would just decode if the string was not None. But this change only does the decoding if the description is not of text_type. If the description is not None, then it should always be of a text_type. Was there a case that it wasn\u0027t text_type?","commit_id":"50a3e9a57ed12b5fc6780c38fbadf59ecb3fd377"},{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"e4cfe82abfd136dfaa45057f82e1e3dff1f2f371","unresolved":false,"context_lines":[{"line_number":268,"context_line":""},{"line_number":269,"context_line":"        description \u003d (alarm_definition_row[\u0027description\u0027]"},{"line_number":270,"context_line":"                       if alarm_definition_row[\u0027description\u0027] is not None else None)"},{"line_number":271,"context_line":"        if description and not isinstance(description, six.text_type):"},{"line_number":272,"context_line":"            description \u003d description.decode(\u0027utf8\u0027)"},{"line_number":273,"context_line":""},{"line_number":274,"context_line":"        expression \u003d alarm_definition_row[\u0027expression\u0027].decode(\u0027utf8\u0027)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3a71b18c_ed1d3467","line":271,"in_reply_to":"3a71b18c_f5c05952","updated":"2016-12-09 17:41:03.000000000","message":"So, I think the problem is that the description was not properly encoded to utf8 when the alarm definition was created. \n\nI think the function\n\ndef get_query_alarm_definition_description(alarm_definition,\n                                           return_none\u003dFalse):\n    if \u0027description\u0027 in alarm_definition:\n        return alarm_definition[\u0027description\u0027]\n    else:\n        if return_none:\n            return None\n        else:\n            return \u0027\u0027\n\nis missing a conversion to utf8 on it. Should the function be written as\n\ndef get_query_alarm_definition_description(alarm_definition,\n                                           return_none\u003dFalse):\n    if \u0027description\u0027 in alarm_definition:\n        return alarm_definition[\u0027description\u0027].decode(\u0027utf8\u0027)\n    else:\n        if return_none:\n            return None\n        else:\n            return \u0027\u0027\n\nwith the conversion to utf8.\n\nThere are other functions in this file that do the following:\n\ndef get_query_alarm_definition_severity(alarm_definition, return_none\u003dFalse):\n    if \u0027severity\u0027 in alarm_definition:\n        severity \u003d alarm_definition[\u0027severity\u0027]\n        severity \u003d severity.decode(\u0027utf8\u0027).upper()\n        if severity not in [\u0027LOW\u0027, \u0027MEDIUM\u0027, \u0027HIGH\u0027, \u0027CRITICAL\u0027]:\n            raise HTTPUnprocessableEntityError(\u0027Unprocessable Entity\u0027, \u0027Invalid severity\u0027)\n        return severity\n    else:\n        if return_none:\n            return None\n        else:\n            return \u0027LOW\u0027","commit_id":"50a3e9a57ed12b5fc6780c38fbadf59ecb3fd377"},{"author":{"_account_id":4428,"name":"Liyingjun","email":"yinjalee@163.com","username":"liyingjun"},"change_message_id":"b4e87b2cc534d71875c3e629bba2981cd395e5c9","unresolved":false,"context_lines":[{"line_number":268,"context_line":""},{"line_number":269,"context_line":"        description \u003d (alarm_definition_row[\u0027description\u0027]"},{"line_number":270,"context_line":"                       if alarm_definition_row[\u0027description\u0027] is not None else None)"},{"line_number":271,"context_line":"        if description and not isinstance(description, six.text_type):"},{"line_number":272,"context_line":"            description \u003d description.decode(\u0027utf8\u0027)"},{"line_number":273,"context_line":""},{"line_number":274,"context_line":"        expression \u003d alarm_definition_row[\u0027expression\u0027].decode(\u0027utf8\u0027)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3a71b18c_f5c05952","line":271,"in_reply_to":"3a71b18c_f73221a6","updated":"2016-12-06 06:06:31.000000000","message":"The test is: https://github.com/openstack/monasca-api/blob/master/monasca_api/tests/test_alarms.py#L504, not sure if it\u0027s a right case..","commit_id":"50a3e9a57ed12b5fc6780c38fbadf59ecb3fd377"}]}
