Project

General

Profile

Actions

Bug #4135

closed

[events] Events of type 'PullRequestEvent' are accessing the wrong repo/commit

Added by Martin Bornhold over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
27.07.2016
Due date:
% Done:

0%

Estimated time:
Sorting:
Commit Number:
Affected Version:

Description

When handling the PullRequestCreateEvent we are trying to lookup the commit ID's in the target repository. This will lead to a CommitDoesNotExist exception because the (new) commit ID's are only available in the source repository of the PR. A quick check showed that all pull request events are subclasses of the RepoEvent and are passing the target_repo to the RepoEvent constructor. If something later calls the _get_commits_as_dict() function with a commit ID from the source repository it will raise a CommitDoesNotExistError. So this bug could happen on every pull request related event.

Pointer: https://internal-code.rhodecode.com/rhodecode-enterprise-ce/files/8bb872ec7b8e41f464e6ddc811fc99170af56076/rhodecode/events/pullrequest.py#L32

Snippet from the server logs:

2016-07-27 14:43:28.306 DEBUG [routes.middleware] Matched POST /u/martinb/rhodecode-enterprise-ce-fork/pull-request/new
2016-07-27 14:43:28.306 DEBUG [routes.middleware] Route path: '/{repo_name}/pull-request/new', defaults: {'action': u'create', 'controller': u'pullrequests'}
2016-07-27 14:43:28.306 DEBUG [routes.middleware] Match dict: {'action': u'create', 'repo_name': u'u/martinb/rhodecode-enterprise-ce-fork', 'controller': u'pullrequests'}

[ ... ] snip

2016-07-27 14:43:29.906 DEBUG [rhodecode.lib.vcs.backends] Creating instance of hg repository from /home/rhodecode/rhodecode/repositories/rhodecode-enterprise-ce
2016-07-27 14:43:29.906 DEBUG [rhodecode.lib.vcs.client_http] RepoMaker call on /home/rhodecode/rhodecode/repositories/rhodecode-enterprise-ce
2016-07-27 14:43:29.907 DEBUG [rhodecode.lib.vcs.client_http] Calling http://localhost:9900/hg@localrepository
2016-07-27 14:43:29.927 DEBUG [rhodecode.lib.vcs.client_http] Calling http://localhost:9900/hg@get_all_commit_ids
2016-07-27 14:43:29.934 DEBUG [rhodecode.lib.vcs.client_http] Calling http://localhost:9900/hg@lookup
2016-07-27 14:43:29.941 ERROR [root] 82fa7f5f67784ff207230436bad0fc83a4118ced
Traceback (most recent call last):
  File "/nix/store/8419cz1447jjmlq68yli0kx2asr3nz0s-python2.7-rhodecode-enterprise-ce-4.3.0+20160726x120343x2f93a63710fc/lib/python2.7/site-packages/rhodecode/events/repo.py", line 67, in _commits_as_dict
    cs = vcs_repo.get_changeset(commit_id)
  File "/nix/store/8419cz1447jjmlq68yli0kx2asr3nz0s-python2.7-rhodecode-enterprise-ce-4.3.0+20160726x120343x2f93a63710fc/lib/python2.7/site-packages/rhodecode/lib/vcs/backends/base.py", line 528, in get_changeset
    commit_id=commit_id, commit_idx=commit_idx, pre_load=pre_load)
  File "/nix/store/8419cz1447jjmlq68yli0kx2asr3nz0s-python2.7-rhodecode-enterprise-ce-4.3.0+20160726x120343x2f93a63710fc/lib/python2.7/site-packages/rhodecode/lib/vcs/backends/hg/repository.py", line 447, in get_commit
    raw_id, idx = self._remote.lookup(commit_id, both=True)
  File "/nix/store/8419cz1447jjmlq68yli0kx2asr3nz0s-python2.7-rhodecode-enterprise-ce-4.3.0+20160726x120343x2f93a63710fc/lib/python2.7/site-packages/rhodecode/lib/vcs/client_http.py", line 105, in f
    return self._call(name, *args, **kwargs)
  File "/nix/store/8419cz1447jjmlq68yli0kx2asr3nz0s-python2.7-rhodecode-enterprise-ce-4.3.0+20160726x120343x2f93a63710fc/lib/python2.7/site-packages/rhodecode/lib/vcs/client_http.py", line 123, in _call_with_logging
    return RemoteRepo._call(self, name, *args, **kwargs)
  File "/nix/store/8419cz1447jjmlq68yli0kx2asr3nz0s-python2.7-rhodecode-enterprise-ce-4.3.0+20160726x120343x2f93a63710fc/lib/python2.7/site-packages/rhodecode/lib/vcs/exceptions.py", line 182, in wrapper
    raise _EXCEPTION_MAP[kind](*e.args)
CommitDoesNotExistError: 82fa7f5f67784ff207230436bad0fc83a4118ced
2016-07-27 14:43:29.973 DEBUG [root] handling slack event for pullrequest-create
Actions

Also available in: Atom PDF