Skip to content

The initial ping from GHE will fail with organizational hooks #51

Open
@jcaesar

Description

@jcaesar

The cause is rather simply that server.py:41 tries to access a repository entry. The fix can be equally simple.

diff --git a/mattermostgithub/server.py b/mattermostgithub/server.py
index ad26bec..9daee73 100644
--- a/mattermostgithub/server.py
+++ b/mattermostgithub/server.py
@@ -38,7 +38,12 @@ def root():
 
     msg = ""
     if event == "ping":
-        msg = "ping from %s" % data['repository']['full_name']
+        if 'repository' in data:
+            msg = "ping from repository %s" % data['repository']['full_name']
+        elif 'organization' in data:
+            msg = "ping from organization %s by user %s" % (data['organization']['login'], data['sender']['login'])
+        else:
+            msg = "ominous ping…"
     elif event == "pull_request":
         if data['action'] == "opened":
             msg = PullRequest(data).opened()

But now you have me wondering: are organizational hooks even expected to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions