Forums

webhook not working

i read this article on dev commnity. i am getting a 500 error on the webhooks on github. error log on pythonanywhere shows this

2020-06-30 09:25:02,353: Not Found: /favicon.ico
2020-06-30 09:27:06,915: Internal Server Error: /update_server/
Traceback (most recent call last):
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/bluecrab/bluecrab.pythonanywhere.com/abott/views.py", line 49, in update
    origin.pull()
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/git/remote.py", line 816, in pull
    res = self._get_fetch_info_from_stderr(proc, progress)
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/git/remote.py", line 676, in _get_fetch_info_from_stderr
    proc.wait(stderr=stderr_text)
  File "/home/bluecrab/.virtualenvs/bluecrab.pythonanywhere.com/lib/python3.6/site-packages/git/cmd.py", line 408, in wait
    raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git pull -v origin
  stderr: 'fatal: Could not read from remote repository.
**NO MATCH**
Please make sure you have the correct access rights
and the repository exists.

'

i ca'n't seem to figure out whats wrong. the website is live though. kindlly check.

Could you post the exact code that you have in your update view?

here

@csrf_exempt
def update(request):
    if request.method == "POST":
        '''
        pass the path of the diectory where your project will be
        stored on PythonAnywhere in the git.Repo() as parameter.
        Here the name of my directory is "test.pythonanywhere.com"
        '''
        repo = git.Repo("bluecrab.pythonanywhere.com")
        origin = repo.remotes.origin

        origin.pull()

        return HttpResponse("Updated code on PythonAnywhere")
    else:
        return HttpResponse("Couldn't update the code on PythonAnywhere")

Can you git pull in that repo in a Bash console?

(bluecrab.pythonanywhere.com) 09:38 ~/bluecrab.pythonanywhere.com (master)$ git pull
The authenticity of host 'github.com (140.82.114.4)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,140.82.114.4' (RSA) to the list of known hosts.
Enter passphrase for key '/home/bluecrab/.ssh/id_rsa':
remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done.
From github.com:smyja/tweetscape
be770b2..9c9dfed master -> origin/master
Updating ace1da7..9c9dfed
error: Your local changes to the following files would be overwritten by merge:
abott/views.py
Please, commit your changes or stash them before you can merge.
Aborting

i ran git commit too

(bluecrab.pythonanywhere.com) 17:38 ~/bluecrab.pythonanywhere.com (master)$ git commit -m "changed another view r"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"                                                                                                  
  git config --global user.name "Your Name"

to set your account's default identity.                                                                                                             
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <bluecrab@4261811f904c>) not allowed                                                                                   
(bluecrab.pythonanywhere.com) 17:41 ~/bluecrab.pythonanywhere.com (master)$ git config --global user.email "myemail@egmail.com"                 
(bluecrab.pythonanywhere.com) 17:42 ~/bluecrab.pythonanywhere.com (master)$ git config --global user.name "myusername"                                   
(bluecrab.pythonanywhere.com) 17:43 ~/bluecrab.pythonanywhere.com (master)$ git commit -m "changed another view r"
On branch master                                                                                                                                    
Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.                                                                      
  (use "git pull" to update your local branch)                                                                                                      
Changes not staged for commit:                                                                                                                      
        modified:   abott/views.py                                                                                                                  
        modified:   twee/settings.py

Untracked files:                                                                                                                                    
        abott/__pycache__/__init__.cpython-36.pyc                                                                                                   
        abott/__pycache__/admin.cpython-36.pyc                                                                                                      
        abott/__pycache__/models.cpython-36.py

You have local changes and, if you pulled, they would be overwritten. You need to either commit them, stash them or checkout the files to revert them.

Your commits did not commit anything because you did not 'git add' the files in question before your committed.

i have done this. i am not sure this is the reason why my github webhooks is not delivering.

well, i have gotten it to work.

Hey Bluecrab, what was causing the 500 error to fire? how did you solve it? i am running in the same error and even if the cause might be different, your approach could be of help

@BoS76 We need more details to help you.