)]}'
{"mistral/services/security.py":[{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"0e979532287a3d31b0db69f091d3d5db4efa0fc1","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        return auth_ctx.MistralContext("},{"line_number":68,"context_line":"            user\u003dclient.session.get_user_id(),"},{"line_number":69,"context_line":"            tenant\u003dproject_id,"},{"line_number":70,"context_line":"            auth_token\u003dclient.session.get_auth_headers().get(\u0027X-Auth-Token\u0027),"},{"line_number":71,"context_line":"            is_trust_scoped\u003dTrue,"},{"line_number":72,"context_line":"            trust_id\u003dtrust_id,"},{"line_number":73,"context_line":"        )"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_88ecfc8f","line":70,"updated":"2017-07-11 11:06:15.000000000","message":"I also faced the issue that with sessions it is unclear where you get the token from. Though, I\u0027m not sure getting it from the headers is the way to go here. Is there any official guidance?","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":7700,"name":"Nikolay Mahotkin","email":"nikolay.makhotkin@gmail.com","username":"nmakhotkin"},"change_message_id":"4ccd86207460d5f7c3eac8b1b476cf089a0e47c5","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        return auth_ctx.MistralContext("},{"line_number":68,"context_line":"            user\u003dclient.session.get_user_id(),"},{"line_number":69,"context_line":"            tenant\u003dproject_id,"},{"line_number":70,"context_line":"            auth_token\u003dclient.session.get_auth_headers().get(\u0027X-Auth-Token\u0027),"},{"line_number":71,"context_line":"            is_trust_scoped\u003dTrue,"},{"line_number":72,"context_line":"            trust_id\u003dtrust_id,"},{"line_number":73,"context_line":"        )"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_48825dca","line":70,"in_reply_to":"3f1d235d_88ecfc8f","updated":"2017-07-11 11:29:24.000000000","message":"oh, I just saw that commit with session is now reverted. Sorry, I\u0027ll fix it.\nOfficial guidance about session to get token says that we should use get_auth_headers: \n\n  https://github.com/openstack/keystoneauth/blob/master/keystoneauth1/session.py#L831-L851\n\nsee the warning.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"0e979532287a3d31b0db69f091d3d5db4efa0fc1","unresolved":false,"context_lines":[{"line_number":86,"context_line":""},{"line_number":87,"context_line":"    ctx \u003d auth_ctx.ctx()"},{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_a86c5808","line":90,"range":{"start_line":89,"start_character":6,"end_line":90,"end_character":70},"updated":"2017-07-11 11:06:15.000000000","message":"Grammar seems to be a bit off here.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":7700,"name":"Nikolay Mahotkin","email":"nikolay.makhotkin@gmail.com","username":"nmakhotkin"},"change_message_id":"4ccd86207460d5f7c3eac8b1b476cf089a0e47c5","unresolved":false,"context_lines":[{"line_number":86,"context_line":""},{"line_number":87,"context_line":"    ctx \u003d auth_ctx.ctx()"},{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_a870d109","line":90,"range":{"start_line":89,"start_character":6,"end_line":90,"end_character":70},"in_reply_to":"3f1d235d_a86c5808","updated":"2017-07-11 11:29:24.000000000","message":"yes, will fix.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"0e979532287a3d31b0db69f091d3d5db4efa0fc1","unresolved":false,"context_lines":[{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"},{"line_number":94,"context_line":"        keystone_client \u003d keystone.client_for_trusts(trust_id)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_282e08a5","line":91,"range":{"start_line":91,"start_character":31,"end_line":91,"end_character":55},"updated":"2017-07-11 11:06:15.000000000","message":"Is it possible that ctx.trust_id is set to any other value than trust_id or None? If it can only be \u003d\u003dtrust_id, I\u0027d rather we use the truthy value in the condition. If it can be something else, can you please mention and example?","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":7700,"name":"Nikolay Mahotkin","email":"nikolay.makhotkin@gmail.com","username":"nmakhotkin"},"change_message_id":"4ccd86207460d5f7c3eac8b1b476cf089a0e47c5","unresolved":false,"context_lines":[{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"},{"line_number":94,"context_line":"        keystone_client \u003d keystone.client_for_trusts(trust_id)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_a8de91d7","line":91,"range":{"start_line":91,"start_character":31,"end_line":91,"end_character":55},"in_reply_to":"3f1d235d_282e08a5","updated":"2017-07-11 11:29:24.000000000","message":"if it is None then we should exit from function on line 85. Then we continue work and trust_id must not be None. \n\nTrust can be deleted only by trustee so if we have trust_id\u003d\u003dctx.trust_id then it means that we are trustee and simply initialize client with existing token. What is wrong here?","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":7700,"name":"Nikolay Mahotkin","email":"nikolay.makhotkin@gmail.com","username":"nmakhotkin"},"change_message_id":"f0578effdfa3cb87da016937eb127305f74e1f7c","unresolved":false,"context_lines":[{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"},{"line_number":94,"context_line":"        keystone_client \u003d keystone.client_for_trusts(trust_id)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_ebd92022","line":91,"range":{"start_line":91,"start_character":31,"end_line":91,"end_character":55},"in_reply_to":"3f1d235d_587228af","updated":"2017-07-11 13:20:37.000000000","message":"This can happen if we are trying to delete trigger within the workflow that was created from trigger :)\n\nSo, cron-trigger creates an execution, then execution tries somehow to call action mistral.cron_triggers_delete name\u003d\"my_trigger\". Current execution is created from trigger so its context contain is_trust_scoped\u003dtrue but does not contain trust_id (only token). So here we use client_for_trusts().\n\nProbably it is not the only case for that.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"93c5979c762555d885bc5118a279d514f258e448","unresolved":false,"context_lines":[{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"},{"line_number":94,"context_line":"        keystone_client \u003d keystone.client_for_trusts(trust_id)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_587228af","line":91,"range":{"start_line":91,"start_character":31,"end_line":91,"end_character":55},"in_reply_to":"3f1d235d_a8de91d7","updated":"2017-07-11 12:43:19.000000000","message":"Thanks. But is it possible that ctx.trust_id !\u003d trust_id? I searched through the code and couldn\u0027t identify a case when this can happen. Though it is not easy to reason about the execution paths of this part of the code so I may have missed something.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"165188dd7c74ec37a06acfcfb6197a6156914540","unresolved":false,"context_lines":[{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    # If we have already initialized context during the trigger processing."},{"line_number":90,"context_line":"    # So we don\u0027t need request the token from the trust one more time."},{"line_number":91,"context_line":"    if ctx.is_trust_scoped and ctx.trust_id \u003d\u003d trust_id:"},{"line_number":92,"context_line":"        keystone_client \u003d keystone.client()"},{"line_number":93,"context_line":"    else:"},{"line_number":94,"context_line":"        keystone_client \u003d keystone.client_for_trusts(trust_id)"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_2e21664e","line":91,"range":{"start_line":91,"start_character":31,"end_line":91,"end_character":55},"in_reply_to":"3f1d235d_ebd92022","updated":"2017-07-11 13:41:08.000000000","message":"I may be mistaken but the only case in the whole Mistral code base where is_trust_scoped\u003dTrue is written or set is here in security.py create_context(). This is called when the trigger starts the execution but this actually sets the trust as well mistral/services/security.py:72\nSorry for being a little picky but I think the ctx.trust_id can never be different from trust_id. The biggest problem, though is that reasoning about this feature is practically impossible at the moment.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"}],"mistral/services/triggers.py":[{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"0e979532287a3d31b0db69f091d3d5db4efa0fc1","unresolved":false,"context_lines":[{"line_number":143,"context_line":"        # Delete trust only together with deleting trigger."},{"line_number":144,"context_line":"        security.delete_trust(trust_id)"},{"line_number":145,"context_line":""},{"line_number":146,"context_line":"    return modified_count"},{"line_number":147,"context_line":""},{"line_number":148,"context_line":""},{"line_number":149,"context_line":"def create_event_trigger(name, exchange, topic, event, workflow_id,"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_ce1b1d71","line":146,"range":{"start_line":146,"start_character":11,"end_line":146,"end_character":25},"updated":"2017-07-11 11:06:15.000000000","message":"Soft: If this is intended to be used as a truth value, I\u0027d rather we converted it into that. This setup now exposes the internal behavior of this function which is usually not desired.","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"}],"mistral/tests/unit/api/v2/test_cron_triggers.py":[{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"0e979532287a3d31b0db69f091d3d5db4efa0fc1","unresolved":false,"context_lines":[{"line_number":60,"context_line":"MOCK_WF \u003d mock.MagicMock(return_value\u003dWF)"},{"line_number":61,"context_line":"MOCK_TRIGGER \u003d mock.MagicMock(return_value\u003dTRIGGER_DB)"},{"line_number":62,"context_line":"MOCK_TRIGGERS \u003d mock.MagicMock(return_value\u003d[TRIGGER_DB])"},{"line_number":63,"context_line":"MOCK_DELETE \u003d mock.MagicMock(return_value\u003d1)"},{"line_number":64,"context_line":"MOCK_EMPTY \u003d mock.MagicMock(return_value\u003d[])"},{"line_number":65,"context_line":"MOCK_NOT_FOUND \u003d mock.MagicMock(side_effect\u003dexc.DBEntityNotFoundError())"},{"line_number":66,"context_line":"MOCK_DUPLICATE \u003d mock.MagicMock(side_effect\u003dexc.DBDuplicateEntryError())"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f1d235d_dd1e2d73","line":63,"range":{"start_line":63,"start_character":42,"end_line":63,"end_character":43},"updated":"2017-07-11 11:06:15.000000000","message":"Soft: should be synchronized with the comment in triggers.py","commit_id":"4d3efca03917745eeb5b18084d85f049a25300f3"}]}
