# HG changeset patch # User Mads Kiilerich # Date 1584461759 -3600 # Node ID 2fa9f497faacf13a2a6e8438f85abeea4ca83a92 # Parent e98f6338829cc795ce067c8c4ec6831887b890cc repos: separate repo creation from form validation The broad catching of Exception in the repo creation controller is conceptually bad. It also caused misleading "Error creating repository None" when form validation failed with anything but formencode.Invalid . For now, just constrain the broad exception handling to only cover repo creation. It is a bug if form validation fails in unexpected ways, and we want it reported as a crash that we can fix. diff -r e98f6338829c -r 2fa9f497faac kallithea/controllers/admin/repos.py --- a/kallithea/controllers/admin/repos.py Tue Mar 17 00:16:52 2020 +0100 +++ b/kallithea/controllers/admin/repos.py Tue Mar 17 17:15:59 2020 +0100 @@ -112,17 +112,11 @@ @NotAnonymous() def create(self): self.__load_defaults() - form_result = {} try: # CanWriteGroup validators checks permissions of this POST form_result = RepoForm(repo_groups=c.repo_groups, landing_revs=c.landing_revs_choices)() \ .to_python(dict(request.POST)) - - # create is done sometimes async on celery, db transaction - # management is handled there. - task = RepoModel().create(form_result, request.authuser.user_id) - task_id = task.task_id except formencode.Invalid as errors: log.info(errors) return htmlfill.render( @@ -133,6 +127,11 @@ force_defaults=False, encoding="UTF-8") + try: + # create is done sometimes async on celery, db transaction + # management is handled there. + task = RepoModel().create(form_result, request.authuser.user_id) + task_id = task.task_id except Exception: log.error(traceback.format_exc()) msg = (_('Error creating repository %s')