)]}'
{"anchor/validators.py":[{"author":{"_account_id":1528,"name":"Stanislaw Pitucha","email":"viraptor@gmail.com","username":"stanislaw-pitucha"},"change_message_id":"de777941255e551d157126f4ec6549e297492834","unresolved":false,"context_lines":[{"line_number":29,"context_line":"    data \u003d name.get_entries_by_nid_name(\u0027CN\u0027)"},{"line_number":30,"context_line":"    try:"},{"line_number":31,"context_line":"        return data[0].get_value()"},{"line_number":32,"context_line":"    except IndexError:"},{"line_number":33,"context_line":"        raise ValidationError(\"Failed to retrieve CN from CSR\")"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_55f1f8ff","line":32,"updated":"2015-06-17 10:23:40.000000000","message":"could you check for len(data) instead? get_value() could potentially raise an IndexError as well internally","commit_id":"eacec5a5dd9ec6f9d3617cac005f37a2a5c2ea58"},{"author":{"_account_id":979,"name":"Dave Walker","email":"email@daviey.com","username":"davewalker"},"change_message_id":"90bc2963235edbbeafea9dec9e3d52537a066887","unresolved":false,"context_lines":[{"line_number":29,"context_line":"    data \u003d name.get_entries_by_nid_name(\u0027CN\u0027)"},{"line_number":30,"context_line":"    try:"},{"line_number":31,"context_line":"        return data[0].get_value()"},{"line_number":32,"context_line":"    except IndexError:"},{"line_number":33,"context_line":"        raise ValidationError(\"Failed to retrieve CN from CSR\")"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_4a28729a","line":32,"in_reply_to":"fa32b979_2a72ce49","updated":"2015-06-17 11:17:12.000000000","message":"But does it matter?  Either way, we failed to retrieve the CN from the CSR?\n\nWe have two unit tests, one that tests successful retrieval of CN from CSR, and one that tests we correctly handle an omission of CN.\n\nThis should mean that we don\u0027t get silent fails for cases that should work, but correctly handle any failure where it shouldn\u0027t work.","commit_id":"eacec5a5dd9ec6f9d3617cac005f37a2a5c2ea58"},{"author":{"_account_id":1528,"name":"Stanislaw Pitucha","email":"viraptor@gmail.com","username":"stanislaw-pitucha"},"change_message_id":"f200c8f101b1b984ef9a3ee42d099c6f5c3d0af9","unresolved":false,"context_lines":[{"line_number":29,"context_line":"    data \u003d name.get_entries_by_nid_name(\u0027CN\u0027)"},{"line_number":30,"context_line":"    try:"},{"line_number":31,"context_line":"        return data[0].get_value()"},{"line_number":32,"context_line":"    except IndexError:"},{"line_number":33,"context_line":"        raise ValidationError(\"Failed to retrieve CN from CSR\")"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_9d38063f","line":32,"in_reply_to":"fa32b979_4a28729a","updated":"2015-06-17 11:37:00.000000000","message":"It makes a difference to the operator in case get_value() or anything below is broken and happens to raise an IndexError:\n\nWith just IndexError catching:\n- ValidationError, \"server_group\" check failed, no traceback - looks like validation problem\n- operator thinking - what happened? CN is right there! what\u0027s wrong with this CSR?\n\nChecking len() instead:\n- IndexError, Traceback: ...\n- operator sees the issue is with Anchor, not their CSR\n\nI really don\u0027t want us to confuse the operator and make him chase issues in wrong places.","commit_id":"eacec5a5dd9ec6f9d3617cac005f37a2a5c2ea58"},{"author":{"_account_id":979,"name":"Dave Walker","email":"email@daviey.com","username":"davewalker"},"change_message_id":"4f873f13316cd558ba1a85248a2f8f887aaaed83","unresolved":false,"context_lines":[{"line_number":29,"context_line":"    data \u003d name.get_entries_by_nid_name(\u0027CN\u0027)"},{"line_number":30,"context_line":"    try:"},{"line_number":31,"context_line":"        return data[0].get_value()"},{"line_number":32,"context_line":"    except IndexError:"},{"line_number":33,"context_line":"        raise ValidationError(\"Failed to retrieve CN from CSR\")"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_c79d5bbd","line":32,"in_reply_to":"fa32b979_55f1f8ff","updated":"2015-06-17 10:38:49.000000000","message":"I\u0027m not sure I see the value in doing an extra check as I was trying to follow the mantra of EAFP (http://stackoverflow.com/a/11360880).  If *any* IndexError is raised, we\u0027ll catch it here.. no?","commit_id":"eacec5a5dd9ec6f9d3617cac005f37a2a5c2ea58"},{"author":{"_account_id":1528,"name":"Stanislaw Pitucha","email":"viraptor@gmail.com","username":"stanislaw-pitucha"},"change_message_id":"44edfccf99485b2a00a0b03d0bb08549987d790c","unresolved":false,"context_lines":[{"line_number":29,"context_line":"    data \u003d name.get_entries_by_nid_name(\u0027CN\u0027)"},{"line_number":30,"context_line":"    try:"},{"line_number":31,"context_line":"        return data[0].get_value()"},{"line_number":32,"context_line":"    except IndexError:"},{"line_number":33,"context_line":"        raise ValidationError(\"Failed to retrieve CN from CSR\")"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"fa32b979_2a72ce49","line":32,"in_reply_to":"fa32b979_c79d5bbd","updated":"2015-06-17 11:01:54.000000000","message":"The resulting exception should be different. If it comes from `data[0]`, then it is a real validation failure. If it comes from `get_value()` then it is a valid internal error which may actually mean we fail at interaction with native openssl code - we shouldn\u0027t be logging \"Failed to retrieve CN from CSR\" in that case, but rather the IndexError itself. I believe ValidationError doesn\u0027t even result in the stack being logged, so we\u0027d never know which scenario happened.","commit_id":"eacec5a5dd9ec6f9d3617cac005f37a2a5c2ea58"}]}
