diff --git a/kallithea/lib/utils2.py b/kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py +++ b/kallithea/lib/utils2.py @@ -430,6 +430,9 @@ def obfuscate_url_pw(engine): return str(_url) +class HookEnvironmentError(Exception): pass + + def get_hook_environment(): """ Get hook context by deserializing the global KALLITHEA_EXTRAS environment @@ -441,15 +444,16 @@ def get_hook_environment(): """ try: - extras = json.loads(os.environ['KALLITHEA_EXTRAS']) + kallithea_extras = os.environ['KALLITHEA_EXTRAS'] except KeyError: - raise Exception("Environment variable KALLITHEA_EXTRAS not found") + raise HookEnvironmentError("Environment variable KALLITHEA_EXTRAS not found") + extras = json.loads(kallithea_extras) try: - for k in ['username', 'repository', 'scm', 'action', 'ip']: + for k in ['username', 'repository', 'scm', 'action', 'ip', 'config']: extras[k] except KeyError: - raise Exception('Missing key %s in KALLITHEA_EXTRAS %s' % (k, extras)) + raise HookEnvironmentError('Missing key %s in KALLITHEA_EXTRAS %s' % (k, extras)) return AttributeDict(extras)