# HG changeset patch # User Marcin Kuzminski # Date 2019-12-02 13:26:56 # Node ID 15b821faef4b69e5b43a21631a886e6d361331d2 # Parent 19a6ab7e5b4d4dd06cbe8103b4f2922a0c6b3472 hovercards: handle unknown commits on repo by returning 404 instead of 500 error. diff --git a/rhodecode/apps/hovercards/views.py b/rhodecode/apps/hovercards/views.py --- a/rhodecode/apps/hovercards/views.py +++ b/rhodecode/apps/hovercards/views.py @@ -22,6 +22,7 @@ import re import logging import collections +from pyramid.httpexceptions import HTTPNotFound from pyramid.view import view_config from rhodecode.apps._base import BaseAppView, RepoAppView @@ -33,6 +34,7 @@ from rhodecode.lib.codeblocks import fil from rhodecode.lib.index import searcher_from_config from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int from rhodecode.lib.ext_json import json +from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError from rhodecode.lib.vcs.nodes import FileNode from rhodecode.model.db import ( func, true, or_, case, in_filter_generator, Repository, RepoGroup, User, UserGroup, PullRequest) @@ -99,5 +101,9 @@ class HoverCardsRepoView(RepoAppView): c = self.load_default_context() commit_id = self.request.matchdict['commit_id'] pre_load = ['author', 'branch', 'date', 'message'] - c.commit = self.rhodecode_vcs_repo.get_commit(commit_id=commit_id, pre_load=pre_load) + try: + c.commit = self.rhodecode_vcs_repo.get_commit(commit_id=commit_id, pre_load=pre_load) + except CommitDoesNotExistError: + raise HTTPNotFound() + return self._get_template_context(c)