Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'HTTP_X_HUB_SIGNATURE' #236

Open
smoors opened this issue Jan 25, 2024 · 1 comment
Open

KeyError: 'HTTP_X_HUB_SIGNATURE' #236

smoors opened this issue Jan 25, 2024 · 1 comment

Comments

@smoors
Copy link
Contributor

smoors commented Jan 25, 2024

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
Copy link
Contributor

boegel commented Jan 26, 2024

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants