EESSI / eessi-bot-software-layer

Bot to help with requests to add software installations to the EESSI software layer
GNU General Public License v2.0
0 stars 17 forks source link

KeyError: 'HTTP_X_HUB_SIGNATURE' #236

Open smoors opened 4 months ago

smoors commented 4 months ago

in trying to setup the bot in our local cluster, i got the error below:

[20240124-T15:36:40] WARNING: A crash occurred! Traceback (most recent call last): File "/apps/brussel/RL8/skylake-ib/software/bot_env/0.2.0-gfbf-2023a/lib/python3.11/site-packages/pyghee/lib.py", line 166, in process_event event_info = get_event_info(request) ^^^^^^^^^^^^^^^^^^^^^^^ File "/apps/brussel/RL8/skylake-ib/software/bot_env/0.2.0-gfbf-2023a/lib/python3.11/site-packages/pyghee/lib.py", line 33, in get_event_info 'signature-sha1': request.headers['X-Hub-Signature'],


File "/apps/brussel/RL8/skylake-ib/software/Flask/3.0.0-GCCcore-12.3.0/lib/python3.11/site-packages/werkzeug/datastructures/headers.py", line 493, in __getitem__
return self.environ[f"HTTP_{key}"]
~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'HTTP_X_HUB_SIGNATURE'

the problem was that i had forgotten to add the webhook secret, which caused some github app headers to be missing.

before:

Request method: POST Accept: / Content-Type: application/json User-Agent: GitHub-Hookshot/cba1d46 X-GitHub-Delivery: fc3af530-bac5-11ee-9451-03179ccabb01 X-GitHub-Event: issue_comment X-GitHub-Hook-ID: 455889230 X-GitHub-Hook-Installation-Target-ID: 802331 X-GitHub-Hook-Installation-Target-Type: integration

after adding the webhook secret:

Request method: POST Accept: / Content-Type: application/json User-Agent: GitHub-Hookshot/cba1d46 X-GitHub-Delivery: 5ebd66d0-baf2-11ee-85b5-0d673f6422cc X-GitHub-Event: issue_comment X-GitHub-Hook-ID: 455889230 X-GitHub-Hook-Installation-Target-ID: 802331 X-GitHub-Hook-Installation-Target-Type: integration X-Hub-Signature: sha1=xxx X-Hub-Signature-256: sha256=xxx

boegel commented 4 months ago

We can/should check whether HTTP_X_HUB_SIGNATURE is set, and produce a clear error message when it's not, so people like @smoors are not left guessing what's going on...